Skip to content

Commit a7068c7

Browse files
committed
Fixes #1 . Fix using wrong Role Model
1 parent 55af4d8 commit a7068c7

File tree

2 files changed

+106
-1
lines changed

2 files changed

+106
-1
lines changed

config/permission.php

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
<?php
2+
3+
return [
4+
'models' => [
5+
/*
6+
* When using the "HasPermissions" trait from this package, we need to know which
7+
* Eloquent model should be used to retrieve your permissions. Of course, it
8+
* is often just the "Permission" model but you may use whatever you like.
9+
*
10+
* The model you want to use as a Permission model needs to implement the
11+
* `Spatie\Permission\Contracts\Permission` contract.
12+
*/
13+
'permission' => Spatie\Permission\Models\Permission::class,
14+
/*
15+
* When using the "HasRoles" trait from this package, we need to know which
16+
* Eloquent model should be used to retrieve your roles. Of course, it
17+
* is often just the "Role" model but you may use whatever you like.
18+
*
19+
* The model you want to use as a Role model needs to implement the
20+
* `Spatie\Permission\Contracts\Role` contract.
21+
*/
22+
'role' => Eminiarts\NovaPermissions\Role::class,
23+
],
24+
'table_names' => [
25+
/*
26+
* When using the "HasRoles" trait from this package, we need to know which
27+
* table should be used to retrieve your roles. We have chosen a basic
28+
* default value but you may easily change it to any table you like.
29+
*/
30+
'roles' => 'roles',
31+
/*
32+
* When using the "HasPermissions" trait from this package, we need to know which
33+
* table should be used to retrieve your permissions. We have chosen a basic
34+
* default value but you may easily change it to any table you like.
35+
*/
36+
'permissions' => 'permissions',
37+
/*
38+
* When using the "HasPermissions" trait from this package, we need to know which
39+
* table should be used to retrieve your models permissions. We have chosen a
40+
* basic default value but you may easily change it to any table you like.
41+
*/
42+
'model_has_permissions' => 'model_has_permissions',
43+
/*
44+
* When using the "HasRoles" trait from this package, we need to know which
45+
* table should be used to retrieve your models roles. We have chosen a
46+
* basic default value but you may easily change it to any table you like.
47+
*/
48+
'model_has_roles' => 'model_has_roles',
49+
/*
50+
* When using the "HasRoles" trait from this package, we need to know which
51+
* table should be used to retrieve your roles permissions. We have chosen a
52+
* basic default value but you may easily change it to any table you like.
53+
*/
54+
'role_has_permissions' => 'role_has_permissions',
55+
],
56+
'column_names' => [
57+
/*
58+
* Change this if you want to name the related model primary key other than
59+
* `model_id`.
60+
*
61+
* For example, this would be nice if your primary keys are all UUIDs. In
62+
* that case, name this `model_uuid`.
63+
*/
64+
'model_morph_key' => 'model_id',
65+
],
66+
/*
67+
* When set to true, the required permission/role names are added to the exception
68+
* message. This could be considered an information leak in some contexts, so
69+
* the default setting is false here for optimum safety.
70+
*/
71+
'display_permission_in_exception' => false,
72+
'cache' => [
73+
/*
74+
* By default all permissions are cached for 24 hours to speed up performance.
75+
* When permissions or roles are updated the cache is flushed automatically.
76+
*/
77+
'expiration_time' => \DateInterval::createFromDateString('24 hours'),
78+
/*
79+
* The key to use when tagging and prefixing entries in the cache.
80+
*/
81+
'key' => 'spatie.permission.cache',
82+
/*
83+
* When checking for a permission against a model by passing a Permission
84+
* instance to the check, this key determines what attribute on the
85+
* Permissions model is used to cache against.
86+
*
87+
* Ideally, this should match your preferred way of checking permissions, eg:
88+
* `$user->can('view-posts')` would be 'name'.
89+
*/
90+
'model_key' => 'name',
91+
/*
92+
* You may optionally indicate a specific cache driver to use for permission and
93+
* role caching using any of the `store` drivers listed in the cache.php config
94+
* file. Using 'default' here means to use the `default` set in cache.php.
95+
*/
96+
'store' => 'default',
97+
],
98+
];

src/ToolServiceProvider.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ public function boot(Filesystem $filesystem)
2424
__DIR__ . '/../database/migrations/create_permission_tables.php.stub' => $this->getMigrationFileName($filesystem),
2525
], 'migrations');
2626

27+
$this->publishes([
28+
__DIR__ . '/../config/permission.php' => config_path('permission.php'),
29+
], 'config');
30+
2731
$this->publishes([
2832
__DIR__ . '/../database/seeds/RolesAndPermissionsSeeder.php.stub' => $this->app->databasePath() . "/seeds/RolesAndPermissionsSeeder.php",
2933
], 'seeds');
@@ -42,7 +46,10 @@ public function boot(Filesystem $filesystem)
4246
*/
4347
public function register()
4448
{
45-
//
49+
$this->mergeConfigFrom(
50+
__DIR__ . '/../config/permission.php',
51+
'permission'
52+
);
4653
}
4754

4855
/**

0 commit comments

Comments
 (0)