Skip to content

Commit dc0bc23

Browse files
author
Saurabh Sharma
committed
Add Spatie Laravel Permissions package
1 parent eced354 commit dc0bc23

File tree

4 files changed

+387
-2
lines changed

4 files changed

+387
-2
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
"guzzlehttp/guzzle": "^7.2",
1010
"laravel/framework": "^10.10",
1111
"laravel/sanctum": "^3.2",
12-
"laravel/tinker": "^2.8"
12+
"laravel/tinker": "^2.8",
13+
"spatie/laravel-permission": "^5.10"
1314
},
1415
"require-dev": {
1516
"fakerphp/faker": "^1.9.1",

composer.lock

Lines changed: 83 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/permission.php

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
<?php
2+
3+
return [
4+
5+
'models' => [
6+
7+
/*
8+
* When using the "HasPermissions" trait from this package, we need to know which
9+
* Eloquent model should be used to retrieve your permissions. Of course, it
10+
* is often just the "Permission" model but you may use whatever you like.
11+
*
12+
* The model you want to use as a Permission model needs to implement the
13+
* `Spatie\Permission\Contracts\Permission` contract.
14+
*/
15+
16+
'permission' => Spatie\Permission\Models\Permission::class,
17+
18+
/*
19+
* When using the "HasRoles" trait from this package, we need to know which
20+
* Eloquent model should be used to retrieve your roles. Of course, it
21+
* is often just the "Role" model but you may use whatever you like.
22+
*
23+
* The model you want to use as a Role model needs to implement the
24+
* `Spatie\Permission\Contracts\Role` contract.
25+
*/
26+
27+
'role' => Spatie\Permission\Models\Role::class,
28+
29+
],
30+
31+
'table_names' => [
32+
33+
/*
34+
* When using the "HasRoles" trait from this package, we need to know which
35+
* table should be used to retrieve your roles. We have chosen a basic
36+
* default value but you may easily change it to any table you like.
37+
*/
38+
39+
'roles' => 'roles',
40+
41+
/*
42+
* When using the "HasPermissions" trait from this package, we need to know which
43+
* table should be used to retrieve your permissions. We have chosen a basic
44+
* default value but you may easily change it to any table you like.
45+
*/
46+
47+
'permissions' => 'permissions',
48+
49+
/*
50+
* When using the "HasPermissions" trait from this package, we need to know which
51+
* table should be used to retrieve your models permissions. We have chosen a
52+
* basic default value but you may easily change it to any table you like.
53+
*/
54+
55+
'model_has_permissions' => 'model_has_permissions',
56+
57+
/*
58+
* When using the "HasRoles" trait from this package, we need to know which
59+
* table should be used to retrieve your models roles. We have chosen a
60+
* basic default value but you may easily change it to any table you like.
61+
*/
62+
63+
'model_has_roles' => 'model_has_roles',
64+
65+
/*
66+
* When using the "HasRoles" trait from this package, we need to know which
67+
* table should be used to retrieve your roles permissions. We have chosen a
68+
* basic default value but you may easily change it to any table you like.
69+
*/
70+
71+
'role_has_permissions' => 'role_has_permissions',
72+
],
73+
74+
'column_names' => [
75+
/*
76+
* Change this if you want to name the related pivots other than defaults
77+
*/
78+
'role_pivot_key' => null, //default 'role_id',
79+
'permission_pivot_key' => null, //default 'permission_id',
80+
81+
/*
82+
* Change this if you want to name the related model primary key other than
83+
* `model_id`.
84+
*
85+
* For example, this would be nice if your primary keys are all UUIDs. In
86+
* that case, name this `model_uuid`.
87+
*/
88+
89+
'model_morph_key' => 'model_id',
90+
91+
/*
92+
* Change this if you want to use the teams feature and your related model's
93+
* foreign key is other than `team_id`.
94+
*/
95+
96+
'team_foreign_key' => 'team_id',
97+
],
98+
99+
/*
100+
* When set to true, the method for checking permissions will be registered on the gate.
101+
* Set this to false, if you want to implement custom logic for checking permissions.
102+
*/
103+
104+
'register_permission_check_method' => true,
105+
106+
/*
107+
* When set to true the package implements teams using the 'team_foreign_key'. If you want
108+
* the migrations to register the 'team_foreign_key', you must set this to true
109+
* before doing the migration. If you already did the migration then you must make a new
110+
* migration to also add 'team_foreign_key' to 'roles', 'model_has_roles', and
111+
* 'model_has_permissions'(view the latest version of package's migration file)
112+
*/
113+
114+
'teams' => false,
115+
116+
/*
117+
* When set to true, the required permission names are added to the exception
118+
* message. This could be considered an information leak in some contexts, so
119+
* the default setting is false here for optimum safety.
120+
*/
121+
122+
'display_permission_in_exception' => false,
123+
124+
/*
125+
* When set to true, the required role names are added to the exception
126+
* message. This could be considered an information leak in some contexts, so
127+
* the default setting is false here for optimum safety.
128+
*/
129+
130+
'display_role_in_exception' => false,
131+
132+
/*
133+
* By default wildcard permission lookups are disabled.
134+
*/
135+
136+
'enable_wildcard_permission' => false,
137+
138+
'cache' => [
139+
140+
/*
141+
* By default all permissions are cached for 24 hours to speed up performance.
142+
* When permissions or roles are updated the cache is flushed automatically.
143+
*/
144+
145+
'expiration_time' => \DateInterval::createFromDateString('24 hours'),
146+
147+
/*
148+
* The cache key used to store all permissions.
149+
*/
150+
151+
'key' => 'spatie.permission.cache',
152+
153+
/*
154+
* You may optionally indicate a specific cache driver to use for permission and
155+
* role caching using any of the `store` drivers listed in the cache.php config
156+
* file. Using 'default' here means to use the `default` set in cache.php.
157+
*/
158+
159+
'store' => 'default',
160+
],
161+
];

0 commit comments

Comments
 (0)