From 5332b7390f92dd87ff9f06dc9baedc99e4fa22ee Mon Sep 17 00:00:00 2001 From: alexcaussades Date: Wed, 22 Nov 2023 21:27:17 +0100 Subject: [PATCH] maj update --- app/Http/Controllers/changelogController.php | 12 ++++- app/Http/Controllers/metarController.php | 2 +- .../Controllers/my_fav_plateController.php | 50 +++++++++++++++++++ app/Models/metar_favModel.php | 15 ++++++ public/asset/css/style.css | 20 ++++++++ resources/views/nav-wellcome.blade.php | 1 - resources/views/welcome.blade.php | 41 ++++++++++----- routes/web.php | 13 ++++- 8 files changed, 136 insertions(+), 18 deletions(-) create mode 100644 app/Http/Controllers/my_fav_plateController.php create mode 100644 app/Models/metar_favModel.php diff --git a/app/Http/Controllers/changelogController.php b/app/Http/Controllers/changelogController.php index fe6c786..7695681 100644 --- a/app/Http/Controllers/changelogController.php +++ b/app/Http/Controllers/changelogController.php @@ -2,8 +2,7 @@ namespace App\Http\Controllers; - - +use Carbon\Carbon; class changelogController extends Controller { @@ -15,4 +14,13 @@ public function localadress() return $data; } + + public function info_update() + { + $data = $this->localadress(); + $data = $data[0]; + $date = Carbon::parse($data["date"])->format("d M Y"); + $data["date"] = $date; + return $data; + } } diff --git a/app/Http/Controllers/metarController.php b/app/Http/Controllers/metarController.php index 6b883ab..0380a02 100644 --- a/app/Http/Controllers/metarController.php +++ b/app/Http/Controllers/metarController.php @@ -228,7 +228,7 @@ public function clouds($metar) public function temp_qnh($metar) { - $regexTemparature = "/[0-9]{2}\/[0-9]{2}/"; + $regexTemparature = "/M?[0-9]{2}\/M?[0-9]{2}/"; $regexQNH = "/[Q][0-9]{4}/"; preg_match($regexTemparature, $metar, $temparature); preg_match($regexQNH, $metar, $QNH); diff --git a/app/Http/Controllers/my_fav_plateController.php b/app/Http/Controllers/my_fav_plateController.php new file mode 100644 index 0000000..05ebcc6 --- /dev/null +++ b/app/Http/Controllers/my_fav_plateController.php @@ -0,0 +1,50 @@ +icao; + $vid = $request->vid; + $id_user = auth()->user()->id; + $fav = metar_favModel::where("vid", $vid); + if ($fav == null) { + $fav = new \App\Models\metar_favModel(); + $fav->icao = $icao; + $fav->vid = $vid; + $fav->id_user = $id_user; + $fav->save(); + return response()->json(["status" => "success", "message" => "Saved"]); + } else { + $fav->delete(); + return response()->json(["status" => "success", "message" => "Deleted"]); + } + } + + public function get() + { + $id_user = auth()->user()->id; + $fav = metar_favModel::where("id_user", $id_user)->get(); + $plateforme = []; + foreach ($fav as $key => $value) { + $plateforme[] = $value->icao; + } + return $plateforme; + } + + public function update(Request $request) + { + $icao = $request->icao; + $vid = $request->vid; + $id_user = auth()->user()->id; + $fav = metar_favModel::where("vid", $vid)->where("id_user", $id_user)->first(); + $fav->icao = $icao; + $fav->save(); + return response()->json(["status" => "success", "message" => "Updated"]); + } +} diff --git a/app/Models/metar_favModel.php b/app/Models/metar_favModel.php new file mode 100644 index 0000000..cb401a3 --- /dev/null +++ b/app/Models/metar_favModel.php @@ -0,0 +1,15 @@ + - \ No newline at end of file diff --git a/resources/views/welcome.blade.php b/resources/views/welcome.blade.php index 1e57f71..4caf4b9 100644 --- a/resources/views/welcome.blade.php +++ b/resources/views/welcome.blade.php @@ -20,8 +20,8 @@ @include('nav-wellcome')
-
@@ -117,24 +117,41 @@
@auth() -
+ diff --git a/routes/web.php b/routes/web.php index 50fa3dd..05adfa2 100644 --- a/routes/web.php +++ b/routes/web.php @@ -44,6 +44,7 @@ use App\Http\Controllers\myOnlineServeurController; use App\Http\Controllers\CreatAuhUniqueUsersController; use Symfony\Component\HttpKernel\Controller\ErrorController; +use App\Http\Controllers\my_fav_plateController; /* |-------------------------------------------------------------------------- @@ -69,6 +70,8 @@ /** creation d'un cookie sur laravel */ $whazzup = new whazzupController(); $whazzup = $whazzup->connexion(); + $w = new changelogController(); + $u = $w->info_update(); if (Session::get("ivao_tokens") != null) { $date = new DateTime(); $date->setTimezone(new DateTimeZone('UTC')); @@ -82,13 +85,13 @@ $users_me = $whaz->user_me(); //dd($online->json(), $users_me); $online = json_decode($online, true); - return response()->view('welcome', ["whazzup" => $whazzup, "online" => $online]); + return response()->view('welcome', ["whazzup" => $whazzup, "online" => $online, "update" => $u ]); } if (env("maintenance_mode") == true) { return view('maintenance'); } $online = null; - return response()->view('welcome', ["whazzup" => $whazzup, "online" => $online]); + return response()->view('welcome', ["whazzup" => $whazzup, "online" => $online, "update" => $u]); })->where('client', '[0-9]+')->name("home"); Route::get('/logout', function (Request $request) { @@ -646,3 +649,9 @@ $g = json_decode($u); return $g; }); + +Route::get("test3", function (Request $request) { + $fav = new my_fav_plateController(); + $fav = $fav->get(); + return $fav; +}); \ No newline at end of file