From 66e8b2e3d819ffc6a0ec83f6421ede4d1dfc7330 Mon Sep 17 00:00:00 2001 From: Vedde Date: Tue, 30 Jun 2020 08:52:11 +0200 Subject: [PATCH] Modified EventController.php. --- .../app/Http/Controllers/EventController.php | 19 +++++++++---------- .../views/admin/events/edit.blade.php | 13 ++++++++----- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/skolehjem/app/Http/Controllers/EventController.php b/skolehjem/app/Http/Controllers/EventController.php index e5754f5..0dc11e7 100644 --- a/skolehjem/app/Http/Controllers/EventController.php +++ b/skolehjem/app/Http/Controllers/EventController.php @@ -70,9 +70,10 @@ class EventController extends Controller * @param int $id * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View */ - public function edit(Event $id) + public function edit($id) { - return Response::detect("events.edit", [ "event" => $id ]); + $event = Event::find($id); + return Response::detect("events.edit", [ "event" => $event ]); } /** @@ -82,17 +83,15 @@ class EventController extends Controller * @param int $id * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View */ - public function update(Request $request, Event $id) + public function update(Request $request, $id) { - $requestBody = $request->validate([ - "name" => "unique:events|max:255", - "description" => "max:255" - ]); + $data = $request->all(); - $id->update($requestBody); - $id->save(); + $event = Event::find($id); + $event->update($data); + $event->save(); - return Response::detect("events.update"); + return Response::detect("events.update", [ "event" => $event]); } /** diff --git a/skolehjem/resources/views/admin/events/edit.blade.php b/skolehjem/resources/views/admin/events/edit.blade.php index 91118bc..8356c41 100644 --- a/skolehjem/resources/views/admin/events/edit.blade.php +++ b/skolehjem/resources/views/admin/events/edit.blade.php @@ -6,7 +6,7 @@ @endsection @section("path") - Vis Events / + $event])}}" class="text-white">Vis Events / @endsection @section("content") @@ -14,10 +14,13 @@
$event])}}"> @csrf @method("PUT") - - - - + + + + + + +
@endsection