diff --git a/M6/emensamobile/app/Models/benutzer.php b/M6/emensamobile/app/Models/Benutzer.php similarity index 100% rename from M6/emensamobile/app/Models/benutzer.php rename to M6/emensamobile/app/Models/Benutzer.php diff --git a/M6/emensamobile/app/Models/Gericht.php b/M6/emensamobile/app/Models/Gericht.php new file mode 100644 index 0000000..b140b93 --- /dev/null +++ b/M6/emensamobile/app/Models/Gericht.php @@ -0,0 +1,65 @@ +formatPreis($this->attributes['preisintern']); + } + + function getPreisExtern(){ + return $this->formatPreis($this->attributes['preisextern']); + } + + private function formatPreis($unformatted){ + return number_format($unformatted, 2, ','); + } + + function getBildname (){ + return $this->attributes['bildname']; + } + + function setVegetarischAttribut($value){ + if ($value == 1 || $value == 0){ + $this->attributes['vegetarisch'] = $value; + return; + } + + $parsed = $this->parse_wahrheitswert($value) ; + $this->attributes['vegetarisch'] = $parsed; + } + + function setVeganAttribut($value){ + if ($value == 1 || $value == 0){ + $this->attributes['vegan'] = $value; + return; + } + + $parsed = $this->parse_wahrheitswert($value) ; + $this->attributes['vegetarisch'] = $parsed; + } + + private function parse_wahrheitswert($value){ + $value = strtolower(str_replace(" ", "", $value)); + + if ($value == "yes" || $value == "ja"){ + return 1; + } + elseif ($value == "no" || $value == "nein"){ + return 0; + } + else{ + trigger_error("Could not parse value"); + } + // Wenn versucht wird das in die Datenbank zu schreiben sollte es eine Fehlermeldung geben + } +} diff --git a/M6/emensamobile/app/Models/Gerichte.php b/M6/emensamobile/app/Models/Gerichte.php index b3299db..ccbeb79 100644 --- a/M6/emensamobile/app/Models/Gerichte.php +++ b/M6/emensamobile/app/Models/Gerichte.php @@ -9,14 +9,9 @@ use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Session; -class Gerichte extends Model -{ +class Gerichte extends Model { use HasFactory; - - - - function db_gericht_select_karte() - { + function db_gericht_select_karte(){ try { $sql_gerichte = "SELECT * FROM gericht ORDER BY RAND() LIMIT 5"; diff --git a/M6/emensamobile/config/database.php b/M6/emensamobile/config/database.php index f75b298..fe6e482 100644 --- a/M6/emensamobile/config/database.php +++ b/M6/emensamobile/config/database.php @@ -50,7 +50,7 @@ return [ 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE', 'emensawerbeseite'), 'username' => env('DB_USERNAME', 'root'), - 'password' => env('DB_PASSWORD', 'admin'), + 'password' => env('DB_PASSWORD', 'wm#32'), 'unix_socket' => env('DB_SOCKET', ''), 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', diff --git a/M6/emensamobile/resources/views/main/index.blade.php b/M6/emensamobile/resources/views/main/index.blade.php index 824cac2..a8d9d06 100644 --- a/M6/emensamobile/resources/views/main/index.blade.php +++ b/M6/emensamobile/resources/views/main/index.blade.php @@ -1,5 +1,8 @@ @extends("layouts.main_layout", ['title' => "E-Mensa"]) - + @section("header") @@ -48,14 +51,13 @@ @section("gerichte") - @if (isset($data['error']))
Fehlermeldung
{{$data['beschreibung']}}
@else
-