From a766bfea95d46fcaef717b2035620eb90f522dde Mon Sep 17 00:00:00 2001 From: Neerholt Date: Thu, 27 Aug 2020 15:29:59 +0200 Subject: [PATCH] v0.10.15l - Made role permissions semi done, sometimes it works sometimes it doesn't, it needs some touch up --- .../app/Http/Controllers/RolesController.php | 17 +- .../views/admin/roles/create.blade.php | 375 ++++++++++++------ 2 files changed, 260 insertions(+), 132 deletions(-) diff --git a/skolehjem/app/Http/Controllers/RolesController.php b/skolehjem/app/Http/Controllers/RolesController.php index 83b4143..53794c2 100644 --- a/skolehjem/app/Http/Controllers/RolesController.php +++ b/skolehjem/app/Http/Controllers/RolesController.php @@ -6,6 +6,7 @@ use Illuminate\Http\Request; use Illuminate\Http\Response; use Illuminate\Support\Facades\DB; use Spatie\Permission\Models\Role; +use Illuminate\Database\Eloquent\Collection; class rolesController extends Controller { @@ -57,6 +58,13 @@ class rolesController extends Controller "description" => "required|max:255" ]); + $brugerPermissions = new Collection(); + if (!$request->value === null) { + foreach ($request->value as $valuee) { + $brugerPermissions->add(\Spatie\Permission\Models\Permission::query()->where("name", "=", $valuee)->first()); + } + } + $role = new Role($requestRole); $allRoles = Role::query()->where('name', '=', $request->name)->get(); @@ -66,11 +74,16 @@ class rolesController extends Controller return redirect()->route("roles.store"); else { // Else - Create it $role->save(); + + if (!$brugerPermissions->isEmpty()) { + foreach ($brugerPermissions as $permission) { + \Spatie\Permission\Models\Role::query()->find($role->id)->givePermissionTo($permission); + } + } + $roles = Role::query()->paginate($request->input("limit", 20)); return redirect()->route("roles.index", ['roles' => $roles]); } - - } /** diff --git a/skolehjem/resources/views/admin/roles/create.blade.php b/skolehjem/resources/views/admin/roles/create.blade.php index a4c9a4b..51a9d07 100644 --- a/skolehjem/resources/views/admin/roles/create.blade.php +++ b/skolehjem/resources/views/admin/roles/create.blade.php @@ -14,6 +14,18 @@ td > p, td > input { margin: 0; } + + small { + font-size: 16px; + } + + .form-text { + display: block; + } + + .text-muted { + color: #6c757d !important; + }

Opret Rolle:

@@ -23,136 +35,208 @@ - - - - - - - - - - - - - - - - - - - -
KontoBeskrivelseSe AccountÆndre BilledeÆndre OplysningerÆndre PasswordForgot Password
KontoEmpty
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SideBeskrivelseCreateReadUpdateDeleteFuld Kontrol
Brugere

Empty

Roller

Empty

Nyheder

Empty

Menuplan

Empty

Aktiviteter

Empty

Lokation

Empty

Vaskemaskiner

Empty

Resevationer

Empty

Kontakter

Empty

Vejledning

Empty

Feedback

Empty

+ + +
+ + +
+ + +
+ Her kan alle basale rettigheder for appens forbrugere slås til eller fra. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
KontoBeskrivelseCreateReadDelete
Konto

Egen bruger

Nyheder

Empty

Menuplan

Empty

Aktiviteter

Empty

ReservationerEmpty
Kontakter

Empty

Vejledning

Empty

FeedbackEmpty
+
+ + + +
+ Her kan alle rettigheder for administrationssiden slås til eller fra. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SideBeskrivelseCreateReadUpdateDeleteFuld Kontrol
Admin Panel

Adgang til admin panelet

Brugere

Empty

Roller

Empty

Nyheder

Empty

Menuplan

Empty

Aktiviteter

Empty

Lokation

Empty

Vaskemaskiner

Empty

ReservationerEmpty
Kontakter

Empty

Vejledning

Empty

Feedback

Empty

+
+
@endsection @@ -216,5 +300,36 @@ } }); }) + + //User hide permissions + + $('#konto').hide(); + $('#admin').hide(); + + + //Show konto settings + $("#kontoButton").click(function(){ + var value = $('#kontoButton').text(); + if(value === 'Konto rettigheder'){ + $('#konto').slideDown('slow'); + $('#kontoButton').html('Luk konto rettigheder') + }else{ + $('#konto').slideUp('slow'); + $('#kontoButton').html('Konto rettigheder') + } + }); + + + //Show admin permissions + $("#adminButton").click(function(){ + var value = $('#adminButton').text(); + if(value === 'Admin rettigheder'){ + $('#admin').slideDown('slow'); + $('#adminButton').html('Luk admin rettigheder') + }else{ + $('#admin').slideUp('slow'); + $('#adminButton').html('Admin rettigheder') + } + }); @endsection