diff --git a/skolehjem/app/Http/Controllers/StaffController.php b/skolehjem/app/Http/Controllers/StaffController.php index f09264f..eecf517 100644 --- a/skolehjem/app/Http/Controllers/StaffController.php +++ b/skolehjem/app/Http/Controllers/StaffController.php @@ -53,8 +53,6 @@ class StaffController extends Controller */ public function store(Request $request) { - Log::debug("STORE FUNCTION"); - $data = $request->validate([ "name_first" => "required|max:255", "name_last" => "required|max:255", @@ -64,17 +62,10 @@ class StaffController extends Controller ]); - Log::debug("FINISHED VALIDATION?"); - $staff = new Staff($data); - - Log::debug("CREATED STAFF [NOT PERSISTED YET]"); - $staff->save(); - Log::debug("SAVED STAFF"); - - return view("staff.store"); + return Response::detect("staff.store"); } /** @@ -161,18 +152,9 @@ class StaffController extends Controller * @param int $id * @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View */ - public function destroy($id) + public function destroy(Staff $id) { -// if($id === Auth::id()) { -// $user = Auth::user(); -// $user->delete(); -// } -// else if(Auth::user()->hasPermissionTo("user.delete")) { - $staff = Staff::find($id); - - $staff->delete(); -// } - + $id->delete(); return redirect()->route("staff.index"); } diff --git a/skolehjem/resources/views/admin/staff/index.blade.php b/skolehjem/resources/views/admin/staff/index.blade.php index 88f80ff..f7a55b3 100644 --- a/skolehjem/resources/views/admin/staff/index.blade.php +++ b/skolehjem/resources/views/admin/staff/index.blade.php @@ -26,14 +26,7 @@ {{ $staff->email }} {{ $staff->phone }} $staff->id ]) }}">Update - -
$staff ]) }}" class="w-100"> - @csrf - @method("delete") - - -
- + $staff->id ]) }}">Delete @endforeach