Removed unnecessary code from StaffController.php

This commit is contained in:
Anders 2020-06-29 14:26:39 +02:00
parent 5a136c537c
commit 45a7302640
2 changed files with 4 additions and 29 deletions

View File

@ -53,8 +53,6 @@ class StaffController extends Controller
*/ */
public function store(Request $request) public function store(Request $request)
{ {
Log::debug("STORE FUNCTION");
$data = $request->validate([ $data = $request->validate([
"name_first" => "required|max:255", "name_first" => "required|max:255",
"name_last" => "required|max:255", "name_last" => "required|max:255",
@ -64,17 +62,10 @@ class StaffController extends Controller
]); ]);
Log::debug("FINISHED VALIDATION?");
$staff = new Staff($data); $staff = new Staff($data);
Log::debug("CREATED STAFF [NOT PERSISTED YET]");
$staff->save(); $staff->save();
Log::debug("SAVED STAFF"); return Response::detect("staff.store");
return view("staff.store");
} }
/** /**
@ -161,18 +152,9 @@ class StaffController extends Controller
* @param int $id * @param int $id
* @return \Illuminate\Contracts\Foundation\Application|\Illuminate\Contracts\View\Factory|\Illuminate\View\View * @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()) { $id->delete();
// $user = Auth::user();
// $user->delete();
// }
// else if(Auth::user()->hasPermissionTo("user.delete")) {
$staff = Staff::find($id);
$staff->delete();
// }
return redirect()->route("staff.index"); return redirect()->route("staff.index");
} }

View File

@ -26,14 +26,7 @@
<td>{{ $staff->email }}</td> <td>{{ $staff->email }}</td>
<td>{{ $staff->phone }}</td> <td>{{ $staff->phone }}</td>
<td><a href="{{ route("staff.edit", [ "staff" => $staff->id ]) }}"><img class="w-100" src="{{ asset('/images/icons/pencil-dark.svg') }}" alt="Update"></a></td> <td><a href="{{ route("staff.edit", [ "staff" => $staff->id ]) }}"><img class="w-100" src="{{ asset('/images/icons/pencil-dark.svg') }}" alt="Update"></a></td>
<td> <td><a href="{{ route("staff.destroy", [ "staff" => $staff->id ]) }}"><img class="w-100" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></a></td>
<form method="post" action="{{ route("staff.destroy", [ "staff" => $staff ]) }}" class="w-100">
@csrf
@method("delete")
<button type="submit"><img class="w-100" src="{{ asset('/images/icons/trashcan-dark.svg') }}" alt="Delete"></button>
</form>
</td>
</tr> </tr>
@endforeach @endforeach
</table> </table>