diff --git a/skolehjem/app/Http/Controllers/LocationController.php b/skolehjem/app/Http/Controllers/LocationController.php index 81640df..a7b403c 100644 --- a/skolehjem/app/Http/Controllers/LocationController.php +++ b/skolehjem/app/Http/Controllers/LocationController.php @@ -64,11 +64,11 @@ class LocationController extends Controller // If there already is a washing machine with that name, then don't add it if (count($locations) > 0) - return redirect()->route("locations.index"); + return redirect()->route("washing-machines.index"); else { // Else - Add it $location->save(); $locations = Location::query()->paginate(20); - return redirect()->route("locations.index", ['locations' => $locations]); + return redirect()->route("washing-machines.index", ['locations' => $locations]);//washing-machines.index kan byttes ud med locations.index } } @@ -114,13 +114,13 @@ class LocationController extends Controller // If there already is a washing machine with that name, then don't change it if (count($allMachines) > 0) - return redirect()->route("locations.index"); + return redirect()->route("washing-machines.index"); else { // Else - Change the name $location->update($data); $location->save(); $locations = Location::query()->paginate(20); - return redirect()->route("locations.index", ["locations" => $locations]); + return redirect()->route("washing-machines.index", ["locations" => $locations]); //washing-machines.index kan byttes ud med locations.index } } @@ -148,7 +148,7 @@ class LocationController extends Controller $location->delete(); - return redirect()->route("locations.index"); + return redirect()->route("washing-machines.index");//washing-machines.index kan byttes ud med locations.index } public function nameCheck(Request $request){ diff --git a/skolehjem/app/Http/Controllers/RolesController.php b/skolehjem/app/Http/Controllers/RolesController.php index 3f1b70c..188f23c 100644 --- a/skolehjem/app/Http/Controllers/RolesController.php +++ b/skolehjem/app/Http/Controllers/RolesController.php @@ -29,7 +29,7 @@ class RolesController extends Controller */ public function index(Request $request) { - $roles = Role::query()->where("id", "!=", 1)->paginate(20); + $roles = Role::query()->where("id", "!=", 1)->where("id", "!=", 2)->paginate(20); return Response::detect("roles.index", [ "roles" => $roles]); } @@ -104,7 +104,7 @@ class RolesController extends Controller */ public function edit($id) { - if($id == 1) + if($id == 1 || $id == 2) return redirect()->route("roles.index"); $role = Role::find($id); @@ -120,7 +120,7 @@ class RolesController extends Controller */ public function update(Request $request, $id) { - if($id == 1) + if($id == 1 || $id == 2) return redirect()->route("roles.index"); $data = $request->validate([ @@ -170,7 +170,7 @@ class RolesController extends Controller */ public function destroy($id) { - if($id == 1) + if($id == 1 || $id == 2) return redirect()->route("roles.index"); $role = Role::find($id); @@ -187,7 +187,7 @@ class RolesController extends Controller "\"Update\"". "\"Delete\"". ""; - $roles = DB::table('roles')->where("id", "!=", 1)->where('name', 'LIKE',$request->search.'%')->get(); + $roles = DB::table('roles')->where("id", "!=", 1)->where("id", "!=", 2)->where('name', 'LIKE',$request->search.'%')->get(); if(count($roles) !== 0){ foreach ($roles as $key => $role){ diff --git a/skolehjem/resources/views/admin/layout/base.blade.php b/skolehjem/resources/views/admin/layout/base.blade.php index c896e77..7daf823 100644 --- a/skolehjem/resources/views/admin/layout/base.blade.php +++ b/skolehjem/resources/views/admin/layout/base.blade.php @@ -150,11 +150,6 @@

Aktiviteter

Aktiviteter
@endif - @if(auth()->user()->can('locations.show')) -
-

Lokationer

Lokationer
-
- @endif @if(auth()->user()->can('washing.machine.show'))

Vaskemaskiner

Vaskemaskiner
diff --git a/skolehjem/resources/views/admin/washing-machines/index.blade.php b/skolehjem/resources/views/admin/washing-machines/index.blade.php index a984f5b..4a90035 100644 --- a/skolehjem/resources/views/admin/washing-machines/index.blade.php +++ b/skolehjem/resources/views/admin/washing-machines/index.blade.php @@ -14,6 +14,9 @@ @if(auth()->user()->can('washing.machine.create')) CreateOpret Vaskemaskine @endif + @if(auth()->user()->can('locations.create')) + CreateOpret Vaskemaskine lokation + @endif
- +
+ +
@@ -53,8 +58,43 @@ @endforeach
Navn Lokation
+ + +
+ + + + + + @if(auth()->user()->can('locations.edit')) + + @endif + @if(auth()->user()->can('locations.delete')) + + @endif + + @foreach(\App\Location::query()->get() as $location) + + + + @if(auth()->user()->can('locations.edit')) + + @endif + @if(auth()->user()->can('locations.delete')) + + @endif + + @endforeach +
NavnShowUpdateDelete
{{$location->name}} $location ]) }}">Show $location ]) }}">Update
$location ]) }}" class="w-100 nostyle"> + @csrf + @method("delete") + + +
+
+ {{ $machines->links() }} +
- {{ $machines->links() }}