From 9db169aadb57e8570f9e3226c69c1dad11a9619f Mon Sep 17 00:00:00 2001 From: Neerholt Date: Mon, 17 Aug 2020 12:24:43 +0200 Subject: [PATCH] v0.10.0d - Rolled back menuplan to old system layout and functionality --- .../Http/Controllers/MenuPlanController.php | 47 +++++++++++++++-- skolehjem/app/MenuPlan.php | 2 +- .../2020_06_23_070657_create_menu_plans.php | 8 +-- .../resources/views/admin/index.blade.php | 21 ++++++-- .../views/admin/menuplans/create.blade.php | 50 +++---------------- .../views/admin/menuplans/edit.blade.php | 38 +++----------- .../views/app/menuplans/index.blade.php | 12 ++++- 7 files changed, 92 insertions(+), 86 deletions(-) diff --git a/skolehjem/app/Http/Controllers/MenuPlanController.php b/skolehjem/app/Http/Controllers/MenuPlanController.php index 308c98b..e312c59 100644 --- a/skolehjem/app/Http/Controllers/MenuPlanController.php +++ b/skolehjem/app/Http/Controllers/MenuPlanController.php @@ -60,8 +60,11 @@ class MenuPlanController extends Controller public function store(Request $request) { $requestMenuPlanCreate = $request->validate([ - "week" => "required|max:2", - "menu" => "required", + "week" => "required|max:255", + "monday" => "required|max:255", + "tuesday" => "required|max:255", + "wednesday" => "required|max:255", + "thursday" => "required|max:255", ]); $menuPlan = new MenuPlan($requestMenuPlanCreate); @@ -74,12 +77,25 @@ class MenuPlanController extends Controller $menuPlan->save(); $menuPlans = MenuPlan::query()->paginate($request->input("limit", 20)); + $menuArray = []; + if($request->newsoption == true){ $news = new News(); $news->name = "Ny menuplan"; $news->subname = "Uge " . $menuPlan->week; - $news->content = $menuPlan->menu; + $news->content = + '

Mandag:

'. + '

'.$menuPlan->monday.'


'. + + '

Tirsdag:

'. + '

'.$menuPlan->tuesday.'


'. + + '

Onsdag:

'. + '

'.$menuPlan->wednesday.'


'. + + '

Torsdag:

'. + '

'.$menuPlan->thursday.'

'; $news->type_id = '2'; $news->arrangement_id = $menuPlan->id; @@ -148,7 +164,18 @@ class MenuPlanController extends Controller $news->subname = "Uge " . $menuplan->week; $news->arrangement_id = $menuplan->id; $news->type_id = '2'; - $news->content = $menuplan->menu; + $news->content = + '

Mandag:

'. + '

'.$menuplan->monday.'


'. + + '

Tirsdag:

'. + '

'.$menuplan->tuesday.'


'. + + '

Onsdag:

'. + '

'.$menuplan->wednesday.'


'. + + '

Torsdag:

'. + '

'.$menuplan->thursday.'

'; NewsController::storeAndGet($news); @@ -193,7 +220,17 @@ class MenuPlanController extends Controller '

Uge '. $menuPlan->week. '

'. ''. '
'. - $menuPlan->menu. + '

Mandag:

'. + '

'.$menuPlan->monday.'


'. + + '

Tirsdag:

'. + '

'.$menuPlan->tuesday.'


'. + + '

Onsdag:

'. + '

'.$menuPlan->wednesday.'


'. + + '

Torsdag:

'. + '

'.$menuPlan->thursday.'

'; '
'. ''. ''; diff --git a/skolehjem/app/MenuPlan.php b/skolehjem/app/MenuPlan.php index ad1a5f8..77dc688 100644 --- a/skolehjem/app/MenuPlan.php +++ b/skolehjem/app/MenuPlan.php @@ -15,6 +15,6 @@ class MenuPlan extends Model { //protected variable which contains name of database field(s) to be filled. protected $fillable = [ - 'week', 'menu' + 'week', 'monday', "tuesday", 'wednesday', 'thursday' ]; } diff --git a/skolehjem/database/migrations/2020_06_23_070657_create_menu_plans.php b/skolehjem/database/migrations/2020_06_23_070657_create_menu_plans.php index 06f78b5..ee6d5c9 100644 --- a/skolehjem/database/migrations/2020_06_23_070657_create_menu_plans.php +++ b/skolehjem/database/migrations/2020_06_23_070657_create_menu_plans.php @@ -17,9 +17,11 @@ class CreateMenuPlans extends Migration { Schema::create('menu_plans', function (Blueprint $table) { $table->id(); - $table->string('week', 2); - $table->longText('menu'); - $table->unique('week'); + $table->integer('week')->unique(); + $table->string('monday', 255); + $table->string('tuesday', 255); + $table->string('wednesday', 255); + $table->string('thursday', 255); $table->timestamps(); //$table->text('description'); }); diff --git a/skolehjem/resources/views/admin/index.blade.php b/skolehjem/resources/views/admin/index.blade.php index dcc0e31..268e64d 100644 --- a/skolehjem/resources/views/admin/index.blade.php +++ b/skolehjem/resources/views/admin/index.blade.php @@ -107,7 +107,7 @@ @else -

Der er ingen aktiviteter

+

Der er ingen aktiviteter

@endif @@ -148,13 +148,26 @@ + -
Ugens Menuplan
@if(\App\MenuPlan::query()->where("week", "=", date('W'))->first() !== null) - {!! \App\MenuPlan::query()->where("week", "=", date('W'))->first()->menu !!} + {{-- \App\MenuPlan::query()->where("week", "=", date('W'))->first() --}} + + + {{ \App\MenuPlan::query()->where("week", "=", date('W'))->first()->monday }} + + + {{ \App\MenuPlan::query()->where("week", "=", date('W'))->first()->tuesday }} + + + {{ \App\MenuPlan::query()->where("week", "=", date('W'))->first()->wednesday }} + + + {{ \App\MenuPlan::query()->where("week", "=", date('W'))->first()->thursday }} + @else

Der er ingen menuplan for denne uge

@endif - + @endsection diff --git a/skolehjem/resources/views/admin/menuplans/create.blade.php b/skolehjem/resources/views/admin/menuplans/create.blade.php index 3f3d16c..64f2600 100644 --- a/skolehjem/resources/views/admin/menuplans/create.blade.php +++ b/skolehjem/resources/views/admin/menuplans/create.blade.php @@ -29,20 +29,14 @@ -
-

Mandag:

-

{Mandag}

-


-

Tirsdag:

-

{Tirsdag}

-


-

Onsdag:

-

{Onsdag}

-


-

Torsdag:

-

{Torsdag}

-
- + + + + + + + +