Skip to content

Commit f945268

Browse files
author
Nur Alam
committed
premission append added, resource permission generate refactored, permission view refactored, config refactored, read me updated
1 parent dda17aa commit f945268

15 files changed

+337
-171
lines changed

README.md

Lines changed: 270 additions & 77 deletions
Large diffs are not rendered by default.

config/permission-generator.php

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,64 +11,55 @@
1111
* Custom permissions
1212
*/
1313
'custom-permissions' => [
14-
//
14+
1515
],
1616

1717
/**
18-
* Define controller namespace
18+
* Permission generate controller's namespace
1919
*
2020
* By Default permissions will be generated from all controller's routes
21-
*
22-
* [Note: permissions will be generated from those controller which contains the defined whole or prefix of controller namespace]
2321
*/
24-
'controller-namespace-prefixes' => [
22+
'permission-generate-controllers' => [
2523
'App\Http\Controllers',
2624
],
2725

2826
/**
29-
* Exclude routes by route name
30-
*/
31-
'exclude-routes' => [
32-
// route.name
33-
],
34-
35-
/**
36-
* Exclude routes by controller whole namespace or sub/prefix of controller namespace
27+
* Exclude routes by controller's namespace
3728
*
3829
* By default all auth controller's routes will be excluded from being generated as permission names
3930
*
40-
* [Note: We can exclude routes by defining controller name or namespace-prefix. All the routes associated with controller will be excluded]
31+
* [Note: Exclude routes by defining App\Http\Controller\SomeController::class or namespace-prefix]
4132
*/
4233
'exclude-controllers' => [
43-
// exclude every route which associate with the prefix of controller namespace
4434
'App\Http\Controllers\Auth',
4535
],
4636

4737
/**
48-
* Cache the rendered permission names
38+
* Exclude routes by route name
4939
*/
50-
'cache-permissions' => [
51-
'cacheable' => true,
52-
'cache-driver' => env('CACHE_DRIVER', 'file'),
40+
'exclude-routes' => [
41+
// route.name
5342
],
5443

5544
/**
56-
* Permission card size
57-
*
58-
* [NT: Predefined permission cards works on bootstrap]
45+
* Cache the rendered permission names
5946
*/
60-
'card-size-class' => 'col-md-3 col-lg-3 col-sm-12',
47+
'cache-permissions' => true,
6148

6249
/**
63-
* These tage used to generate permissions on given resources
50+
* ---------------------------------------------------------------------------------------------------------
51+
* This config only used if you want to generate permission names from resources instead of routes
52+
* ---------------------------------------------------------------------------------------------------------
53+
*
54+
* These actions used to generate permissions on given resources
6455
*
65-
* [Ex: create-posts,'edit-posts','view-list-posts' etc]
56+
* [Ex: If resource is posts, then permission will be (create-posts,'edit-posts','view-posts') etc]
6657
*/
67-
'resource-permission-tags' => [
58+
'resource-actions' => [
6859
'create',
6960
'edit',
7061
'show',
7162
'delete',
72-
'view-list'
63+
'view',
7364
],
7465
];

img/append-permissions.png

54.7 KB
Loading

img/department-rouets.png

-59.1 KB
Binary file not shown.

img/permissible-routes-output.png

-58 KB
Binary file not shown.

img/permission-title.png

29.2 KB
Loading

img/permissions.png

-124 KB
Loading

img/routes.png

127 KB
Loading

resources/views/permission.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</div>
1212

1313
@foreach($permissions as $key => $values)
14-
<div class="{{ config('permission-generator.card-size-class') }}">
14+
<div class="col-md-3 col-lg-3 col-sm-12">
1515
<div class="card permission-card">
1616
<div class="card-header permission-header">
1717
<div class="card-title">
@@ -30,7 +30,7 @@
3030
@foreach($values as $route)
3131
<li>
3232
<input type="checkbox" name="permissions[]" value="{{ $route['name'] }}" id="{{ $route['name'] }}" {{ in_array($route['name'],$rolePermissions) ? 'checked' : '' }}>
33-
<label class="form-check-label" for="{{ $route['name'] }}">{{ $route['title'] }}</label>
33+
<label class="form-check-label" for="{{ $route['name'] }}">{{ $route['text'] }}</label>
3434
</li>
3535
@endforeach
3636
</ul>

src/Facades/PermissionsView.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
use RadiateCode\PermissionNameGenerator\Html\Builder;
1212

1313
/**
14-
* @method static Builder withRolePermissions(string $roleName, array $rolePermissions, string $permissionsSaveUrl = null)
15-
* @method static Application|Factory|View view(string $view, array $data = [])
14+
* @method static Builder make(string $view, array $data = [])
15+
* @method static Builder withPermissions(array $resources)
16+
* @method static Builder markRolePermissions(string $roleName, array $rolePermissions, string $permissionsSaveUrl = null)
17+
* @method static Application|Factory|View render()
1618
*
1719
* @see Builder
1820
*/

0 commit comments

Comments
 (0)