From a0a6f1a9cbf4dc9d6c8c4fc291bf02157a2408ee Mon Sep 17 00:00:00 2001 From: Neerholt Date: Mon, 29 Jun 2020 11:48:36 +0200 Subject: [PATCH] Laver edit, show, update,delete controller for contacts --- .../Http/Controllers/ContactController.php | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/skolehjem/app/Http/Controllers/ContactController.php b/skolehjem/app/Http/Controllers/ContactController.php index 3e0213f..6a64f05 100644 --- a/skolehjem/app/Http/Controllers/ContactController.php +++ b/skolehjem/app/Http/Controllers/ContactController.php @@ -61,7 +61,8 @@ class ContactController extends Controller */ public function show($id) { - // + return Response::detect("contacts.show", [ "contacts" => $id]); + } /** @@ -72,7 +73,8 @@ class ContactController extends Controller */ public function edit($id) { - // + $contacts = Contact::find($id); + return Response::detect("contacts.edit", ["contact" => $contacts]); } /** @@ -84,7 +86,15 @@ class ContactController extends Controller */ public function update(Request $request, $id) { - // + + $data = $request->all(); + //FORCED UPDATE + + $contact = Contact::find($id); + $contact->update($data); + $contact->save(); + + return Response::detect("contacts.update", [ "contact" => $contact ]); } /** @@ -95,6 +105,9 @@ class ContactController extends Controller */ public function destroy($id) { - // + + $contact = Contact::find($id); + $contact->delete(); + return redirect()->route("contacts.index"); } }