From b0eda7f8e779fe5a05eb195af654e68f6da75b6a Mon Sep 17 00:00:00 2001 From: frederikpyt Date: Fri, 7 Aug 2020 10:58:50 +0200 Subject: [PATCH] v0.5.10 - Added support for menuplan as news creation --- .../Http/Controllers/MenuPlanController.php | 25 +++++++++++++++++-- .../views/admin/menuplans/create.blade.php | 14 +++++++++++ .../views/admin/menuplans/edit.blade.php | 15 ++++++++++- .../resources/views/app/news/index.blade.php | 4 +-- 4 files changed, 53 insertions(+), 5 deletions(-) diff --git a/skolehjem/app/Http/Controllers/MenuPlanController.php b/skolehjem/app/Http/Controllers/MenuPlanController.php index 6219089..5262b5f 100644 --- a/skolehjem/app/Http/Controllers/MenuPlanController.php +++ b/skolehjem/app/Http/Controllers/MenuPlanController.php @@ -4,6 +4,7 @@ namespace App\Http\Controllers; use App\ExternalLink; use App\MenuPlan; +use App\News; use App\User; use Illuminate\Http\Request; use Illuminate\Http\Response; @@ -64,15 +65,25 @@ class MenuPlanController extends Controller "thursday" => "required|max:255" ]); - $menuPlans = new MenuPlan($requestMenuPlanCreate); + $menuPlan = new MenuPlan($requestMenuPlanCreate); $allMenuPlans = MenuPlan::query()->where('week', '=', $request->week)->get(); if(count($allMenuPlans) > 0) return redirect()->route("menu-plans.index")->with('WeekExists', '

Der findes allerede en menuplan for den uge!

'); else { - $menuPlans->save(); + $menuPlan->save(); $menuPlans = MenuPlan::query()->paginate($request->input("limit", 20)); + + if($request->newsoption == true){ + $news = new News(); + + $news->name = "Ny menuplan Uge " . $menuPlan->week; + $news->content = ""; + + $news->save(); + } + return redirect()->route("menu-plans.index", ['menuPlans' => $menuPlans]); } } @@ -123,6 +134,16 @@ class MenuPlanController extends Controller $menuplan->save(); $menuPlans = MenuPlan::query()->paginate($request->input("limit", 20)); + + if($request->newsoption == true){ + $news = new News(); + + $news->name = "Opdateret menuplan Uge " . $menuplan->week; + $news->content = ""; + + $news->save(); + } + return redirect()->route("menu-plans.index", ['menuPlans' => $menuPlans]); } diff --git a/skolehjem/resources/views/admin/menuplans/create.blade.php b/skolehjem/resources/views/admin/menuplans/create.blade.php index e3d3718..9bfdf5e 100644 --- a/skolehjem/resources/views/admin/menuplans/create.blade.php +++ b/skolehjem/resources/views/admin/menuplans/create.blade.php @@ -10,6 +10,14 @@ @endsection @section("content") +

Opret Menuplan:

@@ -17,6 +25,12 @@ +
diff --git a/skolehjem/resources/views/admin/menuplans/edit.blade.php b/skolehjem/resources/views/admin/menuplans/edit.blade.php index 2cd747a..350deb5 100644 --- a/skolehjem/resources/views/admin/menuplans/edit.blade.php +++ b/skolehjem/resources/views/admin/menuplans/edit.blade.php @@ -10,6 +10,14 @@ @endsection @section("content") +

Rediger Menuplan:

$menuplan ]) }}"> @csrf @@ -24,7 +32,12 @@ - +
@endsection diff --git a/skolehjem/resources/views/app/news/index.blade.php b/skolehjem/resources/views/app/news/index.blade.php index 384e3bc..983cf63 100644 --- a/skolehjem/resources/views/app/news/index.blade.php +++ b/skolehjem/resources/views/app/news/index.blade.php @@ -59,8 +59,8 @@
@foreach(\App\News::query()->orderBy("created_at", "desc")->get() as $new) -
-

{{ $new->name }}

+
+

{{ $new->name }}

{!! $new->content !!}
@endforeach