This commit is contained in:
Sebastian Davaris 2020-06-30 12:41:45 +02:00
commit 73387686b5
7 changed files with 44 additions and 23 deletions

View File

@ -52,6 +52,7 @@ class MenuPlanController extends Controller
public function store(Request $request) public function store(Request $request)
{ {
$requestMenuPlanCreate = $request->validate([ $requestMenuPlanCreate = $request->validate([
"week" => "required|max:2",
"monday" => "required|max:255", "monday" => "required|max:255",
"tuesday" => "required|max:255", "tuesday" => "required|max:255",
"wednesday" => "required|max:255", "wednesday" => "required|max:255",

View File

@ -7,6 +7,6 @@ use Illuminate\Database\Eloquent\Model;
class MenuPlan extends Model class MenuPlan extends Model
{ {
protected $fillable = [ protected $fillable = [
'monday', "tuesday", 'wednesday', 'thursday' 'week', 'monday', "tuesday", 'wednesday', 'thursday'
]; ];
} }

View File

@ -15,6 +15,7 @@ class CreateMenuPlans extends Migration
{ {
Schema::create('menu_plans', function (Blueprint $table) { Schema::create('menu_plans', function (Blueprint $table) {
$table->id(); $table->id();
$table->string('week', 2);
$table->string('monday', 255); $table->string('monday', 255);
$table->string('tuesday', 255); $table->string('tuesday', 255);
$table->string('wednesday', 255); $table->string('wednesday', 255);

View File

@ -13,6 +13,8 @@
<h1>Opret Menuplan:</h1> <h1>Opret Menuplan:</h1>
<form action="{{ action('MenuPlanController@store') }}" method="post"> <form action="{{ action('MenuPlanController@store') }}" method="post">
@csrf @csrf
<label for="week">Uge nr.</label>
<input type="number" name="week" id="week" min="1" max="53" placeholder="1" required>
<label for="monday">Mandag:</label> <label for="monday">Mandag:</label>
<input type="text" name="monday" id="monday" placeholder="Hawaii Pizza" required> <input type="text" name="monday" id="monday" placeholder="Hawaii Pizza" required>
<label for="tuesday">Tirsdag:</label> <label for="tuesday">Tirsdag:</label>

View File

@ -14,6 +14,8 @@
<form method="post" action="{{ route("menu-plans.update", [ "menu_plan" => $menuplan ]) }}"> <form method="post" action="{{ route("menu-plans.update", [ "menu_plan" => $menuplan ]) }}">
@csrf @csrf
@method("PUT") @method("PUT")
<label for="mandag">Uge:</label>
<input type="number" name="week" id="week" min="1" max="53" value="{{ $menuplan->week }}" required>
<label for="mandag">Mandag:</label> <label for="mandag">Mandag:</label>
<input type="text" name="monday" id="mandag" value="{{ $menuplan->monday }}" required> <input type="text" name="monday" id="mandag" value="{{ $menuplan->monday }}" required>
<label for="tirsdag">Tirsdag:</label> <label for="tirsdag">Tirsdag:</label>
@ -23,6 +25,6 @@
<label for="torsdag">Torsdag:</label> <label for="torsdag">Torsdag:</label>
<input type="text" name="thursday" id="torsdag" value="{{ $menuplan->thursday }}" required> <input type="text" name="thursday" id="torsdag" value="{{ $menuplan->thursday }}" required>
<input type="submit" class="btn btn-dark text-white" value="Opret Menuplan"> <input type="submit" class="btn btn-dark text-white" value="Rediger Menuplan">
</form> </form>
@endsection @endsection

View File

@ -12,6 +12,7 @@
@section("content") @section("content")
<table class="tbl"> <table class="tbl">
<tr> <tr>
<th>Uge</th>
<th>Mandag</th> <th>Mandag</th>
<th>Tirsdag</th> <th>Tirsdag</th>
<th>Onsdag</th> <th>Onsdag</th>
@ -21,6 +22,7 @@
</tr> </tr>
@foreach($menuPlans as $menuplan) @foreach($menuPlans as $menuplan)
<tr> <tr>
<td>{{$menuplan->week}}</td>
<td>{{$menuplan->monday}}</td> <td>{{$menuplan->monday}}</td>
<td>{{$menuplan->tuesday}}</td> <td>{{$menuplan->tuesday}}</td>
<td>{{$menuplan->wednesday}}</td> <td>{{$menuplan->wednesday}}</td>

View File

@ -5,26 +5,39 @@
@endsection @endsection
@section("content") @section("content")
<main> <?php
<h1 class="text-center sde-blue mb-0">Menuplan</h1> $Week = date('W'); //Current week
<span class="text-center sde-black-80 bold" id="week">Uge x</span> ?>
<div class="col w-100 mt-auto"> <main onload="myFunction()">
<div class="w-100" id="mandag"> @if($menuPlans->contains('week', $Week)) {{-- If any of the menues in the menu table has the number of the week in the 'week' column, do this --}}
<h3 class="sde-blue bold text-center">Mandag</h3> @foreach($menuPlans as $menuplan)
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc sodales pulvinar congue aenean suspendisse.</p> @if($menuplan->week == $Week)
</div> <h1 class="text-center sde-blue mb-0">Menuplan</h1>
<div class="w-100" id="tirsdag"> <span class="text-center sde-black-80 bold">Uge: {{$menuplan->week}}</span>
<h3 class="sde-blue bold text-center">Tirsdag</h3> <div class="col w-100 mt-auto text-center">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc sodales pulvinar congue aenean suspendisse.</p> <div class="w-100" id="mandag">
</div> <h3 class="sde-blue bold mb-0">Mandag</h3>
<div class="w-100" id="onsdag"> <p>{{$menuplan->monday}}</p>
<h3 class="sde-blue bold text-center">Onsdag</h3> </div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc sodales pulvinar congue aenean suspendisse.</p> <div class="w-100" id="tirsdag">
</div> <h3 class="sde-blue bold mb-0">Tirsdag</h3>
<div class="w-100" id="torsdag"> <p>{{$menuplan->tuesday}}</p>
<h3 class="sde-blue bold text-center">Torsdag</h3> </div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc sodales pulvinar congue aenean suspendisse.</p> <div class="w-100" id="onsdag">
</div> <h3 class="sde-blue bold mb-0">Onsdag</h3>
</div> <p>{{$menuplan->wednesday}}</p>
</div>
<div class="w-100" id="torsdag">
<h3 class="sde-blue bold mb-0">Torsdag</h3>
<p>{{$menuplan->thursday}}</p>
</div>
</div>
@endif
@endforeach
@else
<h1 class="text-center sde-blue mb-0">Menuplan</h1>
<p class="text-center">Der er ingen menuplaner denne uge!</p>
@endif
</main> </main>
{{ $menuPlans->links() }}
@endsection @endsection