├── CHANGELOG.md
├── LICENSE
├── README.md
├── VERSION
├── composer.json
├── config
├── laratrust.php
└── laratrust_seeder.php
├── package-lock.json
├── package.json
├── public
├── img
│ └── logo.png
├── laratrust.css
└── mix-manifest.json
├── resources
├── css
│ └── styles.css
└── views
│ ├── migration.blade.php
│ ├── panel
│ ├── edit.blade.php
│ ├── layout.blade.php
│ ├── pagination.blade.php
│ ├── permissions
│ │ └── index.blade.php
│ ├── roles-assignment
│ │ ├── edit.blade.php
│ │ └── index.blade.php
│ └── roles
│ │ ├── index.blade.php
│ │ └── show.blade.php
│ ├── setup-teams.blade.php
│ └── upgrade-migration.blade.php
├── routes
└── web.php
├── src
├── Checkers
│ ├── CheckersManager.php
│ ├── Role
│ │ ├── RoleChecker.php
│ │ ├── RoleDefaultChecker.php
│ │ └── RoleQueryChecker.php
│ └── User
│ │ ├── UserChecker.php
│ │ ├── UserDefaultChecker.php
│ │ └── UserQueryChecker.php
├── Console
│ ├── AddLaratrustUserTraitUseCommand.php
│ ├── MakePermissionCommand.php
│ ├── MakeRoleCommand.php
│ ├── MakeSeederCommand.php
│ ├── MakeTeamCommand.php
│ ├── MigrationCommand.php
│ ├── SetupCommand.php
│ ├── SetupTeamsCommand.php
│ └── UpgradeCommand.php
├── Contracts
│ ├── LaratrustUser.php
│ ├── Permission.php
│ ├── Role.php
│ └── Team.php
├── Helper.php
├── Http
│ └── Controllers
│ │ ├── PermissionsController.php
│ │ ├── RolesAssignmentController.php
│ │ └── RolesController.php
├── Laratrust.php
├── LaratrustFacade.php
├── LaratrustServiceProvider.php
├── Middleware
│ ├── Ability.php
│ ├── LaratrustMiddleware.php
│ ├── Permission.php
│ └── Role.php
├── Models
│ ├── Permission.php
│ ├── Role.php
│ └── Team.php
└── Traits
│ ├── DynamicUserRelationshipCalls.php
│ ├── HasLaratrustEvents.php
│ ├── HasLaratrustScopes.php
│ └── HasRolesAndPermissions.php
├── stubs
├── permission.stub
├── role.stub
├── seeder.stub
└── team.stub
├── tailwind.config.js
└── webpack.mix.js
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## 6.1.0 (mayo 29, 2020)
2 | - Merge branch 'limit-roles-in-panel' into 6.x
3 | - Update docs
4 | - Update docs
5 | - Use a default model when entering the roles assignment view
6 | - Use display name when available in the panel
7 | - Build for production
8 | - Little improvements on the not removable roles and defaults for previously installed versions
9 | - Add show view for the not editable roles
10 | - Update docs
11 | - Add config file structure
12 | - Add possibility to avoid having roles removed from an user
13 | - Add the possibility to block roles for edit and delete
14 |
15 | ## 6.0.2 (mayo 11, 2020)
16 | - Merge pull request #411 from siarheipashkevich/fix-config-typos
17 | - Fixed config typos
18 | - Update docs
19 | - Merge branch '6.x'
20 | - Fix broken links and update sitemap
21 | - Merge branch '6.x'
22 | - Add some screenshots to the docs
23 | - Merge branch '6.x'
24 |
25 | ## 6.0.1 (mayo 07, 2020)
26 | - Don't register the panel by default
27 |
28 | ## 6.0.0 (mayo 06, 2020)
29 | - Add simple admin panel to manage roles, permissions and roles/permissions assignment to the users
30 | - Change how the Seeder works, in order to only use the role structure we had before
31 | - Remove the method `can` so we now support gates and policies out of the box
32 | - Add `withoutRole` and `withoutPermission` scopes
33 | - Add support to receive multiple roles and permisions in the `whereRoleIs` and `wherePermissionIs` methods.
34 | - Laratrust is now using semver.
35 |
36 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 santigarcor
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # Laratrust (Laravel Package)
4 |
5 | [](//github.com/sponsors/santigarcor)
6 | [](//packagist.org/packages/santigarcor/laratrust)
7 | [](//packagist.org/packages/santigarcor/laratrust)
8 | [](//packagist.org/packages/santigarcor/laratrust)
9 | [](https://github.com/santigarcor/laratrust/actions?query=workflow%3Atests)
10 |
11 | ## Version Compatibility
12 |
13 | | Laravel | Laratrust |
14 | | :--------------- | :-------------------------------------------------- |
15 | | 10.x, 11.X, 12.X | [8.x](//laratrust.santigarcor.me/docs/8.x/) |
16 | | 9.x-10.x | [7.x](//laratrust.santigarcor.me/docs/7.x/) |
17 | | 8.x | [6.x](//laratrust.santigarcor.me/docs/6.x/) |
18 | | 7.x | [6.x](//laratrust.santigarcor.me/docs/6.x/) |
19 | | 6.x | [6.x](//laratrust.santigarcor.me/docs/6.x/) |
20 | | 5.6.x - 5.8.x | [5.2](//laratrust.santigarcor.me/docs/5.2/) |
21 | | 5.3.x - 5.5.x | [5.1](//laratrust.santigarcor.me/docs/5.1/) |
22 | | 5.0.x - 5.2.x | [4.0](//github.com/santigarcor/laratrust/tree/4.0). |
23 |
24 | ## Installation, Configuration and Usage
25 |
26 | To install, configure and learn how to use Laratrust please go to the [Documentation](https://laratrust.santigarcor.me/).
27 |
28 | ## What does Laratrust support?
29 |
30 | - Multiple user models.
31 | - Multiple roles and permissions assignable to users.
32 | - Multiple permissions assignable to roles.
33 | - Roles and permissions verification.
34 | - Roles and permissions caching.
35 | - Events when roles and permissions are added, removed or synced.
36 | - Multiple roles and permissions can be added to users within teams.
37 | - Multiple guards for the middleware.
38 | - A simple administration panel for roles and permissions.
39 | - Laravel gates and policies.
40 |
41 | ## License
42 |
43 | Laratrust is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).
44 |
45 | ## Contributing
46 |
47 | Please report any issue you find in the issues page. Pull requests are more than welcome.
48 |
--------------------------------------------------------------------------------
/VERSION:
--------------------------------------------------------------------------------
1 | 6.1.0
2 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "santigarcor/laratrust",
3 | "description": "This package provides a flexible way to add Role-based Permissions to Laravel",
4 | "keywords": [
5 | "acl",
6 | "authorization",
7 | "laravel",
8 | "laratrust",
9 | "permissions",
10 | "php",
11 | "rbac",
12 | "roles",
13 | "multiusers",
14 | "teams"
15 | ],
16 | "license": "MIT",
17 | "authors": [
18 | {
19 | "name": "Santiago Garcia",
20 | "homepage": "http://santigarcor.me"
21 | }
22 | ],
23 | "require": {
24 | "php": ">=8.1",
25 | "kkszymanowski/traitor": "^1.0",
26 | "laravel/framework": "^10.0|^11.0|^12.0"
27 | },
28 | "require-dev": {
29 | "mockery/mockery": "^1.3.2",
30 | "orchestra/testbench": "^8.0|^9.0|^10.0",
31 | "phpunit/phpunit": "^8.4|^9.0|^10.5|^11.5.3"
32 | },
33 | "autoload": {
34 | "psr-4": {
35 | "Laratrust\\": "src/"
36 | }
37 | },
38 | "autoload-dev": {
39 | "psr-4": {
40 | "Laratrust\\Tests\\": "tests/"
41 | }
42 | },
43 | "config": {
44 | "sort-packages": true
45 | },
46 | "prefer-stable": true,
47 | "minimum-stability": "dev",
48 | "extra": {
49 | "laravel": {
50 | "providers": [
51 | "Laratrust\\LaratrustServiceProvider"
52 | ],
53 | "aliases": {
54 | "Laratrust": "Laratrust\\LaratrustFacade"
55 | }
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/config/laratrust.php:
--------------------------------------------------------------------------------
1 | false,
14 |
15 | /*
16 | |--------------------------------------------------------------------------
17 | | Checkers
18 | |--------------------------------------------------------------------------
19 | |
20 | | Manage Laratrust's role and permissions checkers configurations.
21 | |
22 | */
23 | 'checkers' => [
24 |
25 | /*
26 | |--------------------------------------------------------------------------
27 | | Which permissions checker to use.
28 | |--------------------------------------------------------------------------
29 | |
30 | | Defines if you want to use the roles and permissions checker.
31 | | Available:
32 | | - default: Check for the roles and permissions using the method that Laratrust
33 | | has always used.
34 | | - query: Check for the roles and permissions using direct queries to the database.
35 | | This method doesn't support cache yet.
36 | | - class that extends Laratrust\Checkers\User\UserChecker
37 | */
38 | 'user' => 'default',
39 |
40 | /*
41 | |--------------------------------------------------------------------------
42 | | Which role checker to use.
43 | |--------------------------------------------------------------------------
44 | |
45 | | Defines if you want to use the roles and permissions checker.
46 | | Available:
47 | | - default: Check for the roles and permissions using the method that Laratrust
48 | has always used.
49 | | - query: Check for the roles and permissions using direct queries to the database.
50 | | This method doesn't support cache yet.
51 | | - class that extends Laratrust\Checkers\Role\RoleChecker
52 | */
53 | 'role' => 'default',
54 | ],
55 |
56 | /*
57 | |--------------------------------------------------------------------------
58 | | Cache
59 | |--------------------------------------------------------------------------
60 | |
61 | | Manage Laratrust's cache configurations. It uses the driver defined in the
62 | | config/cache.php file.
63 | |
64 | */
65 | 'cache' => [
66 | /*
67 | |--------------------------------------------------------------------------
68 | | Use cache in the package
69 | |--------------------------------------------------------------------------
70 | |
71 | | Defines if Laratrust will use Laravel's Cache to cache the roles and permissions.
72 | | NOTE: Currently the database check does not use cache.
73 | |
74 | */
75 | 'enabled' => env('LARATRUST_ENABLE_CACHE', env('APP_ENV') === 'production'),
76 |
77 | /*
78 | |--------------------------------------------------------------------------
79 | | Time to store in cache Laratrust's roles and permissions.
80 | |--------------------------------------------------------------------------
81 | |
82 | | Determines the time in SECONDS to store Laratrust's roles and permissions in the cache.
83 | |
84 | */
85 | 'expiration_time' => 3600,
86 | ],
87 |
88 | /*
89 | |--------------------------------------------------------------------------
90 | | Laratrust User Models
91 | |--------------------------------------------------------------------------
92 | |
93 | | This is the array that contains the information of the user models.
94 | | This information is used in the add-trait command, for the roles and
95 | | permissions relationships with the possible user models, and the
96 | | administration panel to add roles and permissions to the users.
97 | |
98 | | The key in the array is the name of the relationship inside the roles and permissions.
99 | |
100 | */
101 | 'user_models' => [
102 | 'users' => \App\Models\User::class,
103 | ],
104 |
105 | /*
106 | |--------------------------------------------------------------------------
107 | | Laratrust Models
108 | |--------------------------------------------------------------------------
109 | |
110 | | These are the models used by Laratrust to define the roles, permissions and teams.
111 | | If you want the Laratrust models to be in a different namespace or
112 | | to have a different name, you can do it here.
113 | |
114 | */
115 | 'models' => [
116 |
117 | 'role' => \App\Models\Role::class,
118 |
119 | 'permission' => \App\Models\Permission::class,
120 |
121 | /**
122 | * Will be used only if the teams functionality is enabled.
123 | */
124 | 'team' => \App\Models\Team::class,
125 | ],
126 |
127 | /*
128 | |--------------------------------------------------------------------------
129 | | Laratrust Tables
130 | |--------------------------------------------------------------------------
131 | |
132 | | These are the tables used by Laratrust to store all the authorization data.
133 | |
134 | */
135 | 'tables' => [
136 |
137 | 'roles' => 'roles',
138 |
139 | 'permissions' => 'permissions',
140 |
141 | /**
142 | * Will be used only if the teams functionality is enabled.
143 | */
144 | 'teams' => 'teams',
145 |
146 | 'role_user' => 'role_user',
147 |
148 | 'permission_user' => 'permission_user',
149 |
150 | 'permission_role' => 'permission_role',
151 | ],
152 |
153 | /*
154 | |--------------------------------------------------------------------------
155 | | Laratrust Foreign Keys
156 | |--------------------------------------------------------------------------
157 | |
158 | | These are the foreign keys used by laratrust in the intermediate tables.
159 | |
160 | */
161 | 'foreign_keys' => [
162 | /**
163 | * User foreign key on Laratrust's role_user and permission_user tables.
164 | */
165 | 'user' => 'user_id',
166 |
167 | /**
168 | * Role foreign key on Laratrust's role_user and permission_role tables.
169 | */
170 | 'role' => 'role_id',
171 |
172 | /**
173 | * Role foreign key on Laratrust's permission_user and permission_role tables.
174 | */
175 | 'permission' => 'permission_id',
176 |
177 | /**
178 | * Role foreign key on Laratrust's role_user and permission_user tables.
179 | */
180 | 'team' => 'team_id',
181 | ],
182 |
183 | /*
184 | |--------------------------------------------------------------------------
185 | | Laratrust Middleware
186 | |--------------------------------------------------------------------------
187 | |
188 | | This configuration helps to customize the Laratrust middleware behavior.
189 | |
190 | */
191 | 'middleware' => [
192 | /**
193 | * Define if the laratrust middleware are registered automatically in the service provider.
194 | */
195 | 'register' => true,
196 |
197 | /**
198 | * Method to be called in the middleware return case.
199 | * Available: abort|redirect.
200 | */
201 | 'handling' => 'abort',
202 |
203 | /**
204 | * Handlers for the unauthorized method in the middlewares.
205 | * The name of the handler must be the same as the handling.
206 | */
207 | 'handlers' => [
208 | /**
209 | * Aborts the execution with a 403 code and allows you to provide the response text.
210 | */
211 | 'abort' => [
212 | 'code' => 403,
213 | 'message' => 'User does not have any of the necessary access rights.',
214 | ],
215 |
216 | /**
217 | * Redirects the user to the given url.
218 | * If you want to flash a key to the session,
219 | * you can do it by setting the key and the content of the message
220 | * If the message content is empty it won't be added to the redirection.
221 | */
222 | 'redirect' => [
223 | 'url' => '/home',
224 | 'message' => [
225 | 'key' => 'error',
226 | 'content' => '',
227 | ],
228 | ],
229 | ],
230 | ],
231 |
232 | 'teams' => [
233 | /*
234 | |--------------------------------------------------------------------------
235 | | Use teams feature in the package
236 | |--------------------------------------------------------------------------
237 | |
238 | | Defines if Laratrust will use the teams feature.
239 | | Please check the docs to see what you need to do in case you have the package already configured.
240 | |
241 | */
242 | 'enabled' => false,
243 |
244 | /*
245 | |--------------------------------------------------------------------------
246 | | Strict check for roles/permissions inside teams
247 | |--------------------------------------------------------------------------
248 | |
249 | | Determines if a strict check should be done when checking if a role or permission is added inside a team.
250 | | If it's false, when checking a role/permission without specifying the team,
251 | | it will check only if the user has added that role/permission ignoring the team.
252 | |
253 | */
254 | 'strict_check' => false,
255 | ],
256 |
257 | /*
258 | |--------------------------------------------------------------------------
259 | | Laratrust Permissions as Gates
260 | |--------------------------------------------------------------------------
261 | |
262 | | Determines if you can check if a user has a permission using the "can" method.
263 | |
264 | */
265 | 'permissions_as_gates' => false,
266 |
267 | /*
268 | |--------------------------------------------------------------------------
269 | | Laratrust Panel
270 | |--------------------------------------------------------------------------
271 | |
272 | | Section to manage everything related with the admin panel for the roles and permissions.
273 | |
274 | */
275 | 'panel' => [
276 | /*
277 | |--------------------------------------------------------------------------
278 | | Laratrust Panel Register
279 | |--------------------------------------------------------------------------
280 | |
281 | | This manages if routes used for the admin panel should be registered.
282 | | Turn this value to false if you don't want to use Laratrust admin panel
283 | |
284 | */
285 | 'register' => false,
286 |
287 | /*
288 | |--------------------------------------------------------------------------
289 | | Laratrust Panel Domain
290 | |--------------------------------------------------------------------------
291 | |
292 | | This is the Domain Laratrust panel for roles and permissions
293 | | will be accessible from.
294 | |
295 | */
296 | 'domain' => env('LARATRUST_PANEL_DOMAIN'),
297 |
298 | /*
299 | |--------------------------------------------------------------------------
300 | | Laratrust Panel Path
301 | |--------------------------------------------------------------------------
302 | |
303 | | This is the URI path where Laratrust panel for roles and permissions
304 | | will be accessible from.
305 | |
306 | */
307 | 'path' => 'laratrust',
308 |
309 | /*
310 | |--------------------------------------------------------------------------
311 | | Laratrust Panel Path
312 | |--------------------------------------------------------------------------
313 | |
314 | | The route where the go back link should point
315 | |
316 | */
317 | 'go_back_route' => '/',
318 |
319 | /*
320 | |--------------------------------------------------------------------------
321 | | Laratrust Panel Route Middleware
322 | |--------------------------------------------------------------------------
323 | |
324 | | These middleware will get added onto each Laratrust panel route.
325 | |
326 | */
327 | 'middleware' => ['web'],
328 |
329 | /*
330 | |--------------------------------------------------------------------------
331 | | Enable permissions assignment
332 | |--------------------------------------------------------------------------
333 | |
334 | | Enable/Disable the permissions assignment to the users.
335 | |
336 | */
337 | 'assign_permissions_to_user' => true,
338 |
339 | /*
340 | |--------------------------------------------------------------------------
341 | | Enable permissions creation
342 | |--------------------------------------------------------------------------
343 | |
344 | | Enable/Disable the possibility to create permissions from the panel.
345 | |
346 | */
347 | 'create_permissions' => true,
348 |
349 | /*
350 | |--------------------------------------------------------------------------
351 | | Add restriction to roles in the panel
352 | |--------------------------------------------------------------------------
353 | |
354 | | Configure which roles can not be editable, deletable and removable.
355 | | To add a role to the restriction, use name of the role here.
356 | |
357 | */
358 | 'roles_restrictions' => [
359 | // The user won't be able to remove roles already assigned to users.
360 | 'not_removable' => [],
361 |
362 | // The user won't be able to edit the role and the permissions assigned.
363 | 'not_editable' => [],
364 |
365 | // The user won't be able to delete the role.
366 | 'not_deletable' => [],
367 | ],
368 | ],
369 | ];
370 |
--------------------------------------------------------------------------------
/config/laratrust_seeder.php:
--------------------------------------------------------------------------------
1 | false,
8 |
9 | /**
10 | * Control if all the laratrust tables should be truncated before running the seeder.
11 | */
12 | 'truncate_tables' => true,
13 |
14 | 'roles_structure' => [
15 | 'superadministrator' => [
16 | 'users' => 'c,r,u,d',
17 | 'payments' => 'c,r,u,d',
18 | 'profile' => 'r,u',
19 | ],
20 | 'administrator' => [
21 | 'users' => 'c,r,u,d',
22 | 'profile' => 'r,u',
23 | ],
24 | 'user' => [
25 | 'profile' => 'r,u',
26 | ],
27 | 'role_name' => [
28 | 'module_1_name' => 'c,r,u,d',
29 | ],
30 | ],
31 |
32 | 'permissions_map' => [
33 | 'c' => 'create',
34 | 'r' => 'read',
35 | 'u' => 'update',
36 | 'd' => 'delete',
37 | ],
38 | ];
39 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "laratrust",
3 | "version": "5.1.0",
4 | "description": "Laratrust Docs",
5 | "directories": {
6 | "doc": "docs",
7 | "test": "tests"
8 | },
9 | "dependencies": {},
10 | "devDependencies": {
11 | "@tailwindcss/custom-forms": "^0.2.1",
12 | "cross-env": "^7.0.2",
13 | "laravel-mix": "^5.0.4",
14 | "tailwindcss": "^1.4.2",
15 | "vuepress": "^0.14.4"
16 | },
17 | "scripts": {
18 | "docs:dev": "vuepress dev docs",
19 | "docs:build": "vuepress build docs",
20 | "dev": "npm run development",
21 | "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
22 | "watch": "npm run development -- --watch",
23 | "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
24 | "prod": "npm run production",
25 | "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
26 | },
27 | "author": "Santiago Garcia C",
28 | "license": "MIT",
29 | "bugs": {
30 | "url": "https://github.com/santigarcor/laratrust/issues"
31 | },
32 | "homepage": "https://github.com/santigarcor/laratrust#readme"
33 | }
34 |
--------------------------------------------------------------------------------
/public/img/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/santigarcor/laratrust/f0b90fca6b378906c3522f9f40ca1691c4a6fd84/public/img/logo.png
--------------------------------------------------------------------------------
/public/laratrust.css:
--------------------------------------------------------------------------------
1 | /*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}main{display:block}h1{font-size:2em;margin:.67em 0}hr{box-sizing:content-box;height:0;overflow:visible}pre{font-family:monospace,monospace;font-size:1em}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,input{overflow:visible}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:.35em .75em .625em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}progress{vertical-align:baseline}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}details{display:block}summary{display:list-item}[hidden],template{display:none}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}button{background-color:transparent;background-image:none;padding:0}button:focus{outline:1px dotted;outline:5px auto -webkit-focus-ring-color}fieldset,ol,ul{margin:0;padding:0}ol,ul{list-style:none}html{font-family:system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;line-height:1.5}*,:after,:before{box-sizing:border-box;border:0 solid #e2e8f0}hr{border-top-width:1px}img{border-style:solid}textarea{resize:vertical}input::-webkit-input-placeholder,textarea::-webkit-input-placeholder{color:#a0aec0}input::-moz-placeholder,textarea::-moz-placeholder{color:#a0aec0}input:-ms-input-placeholder,textarea:-ms-input-placeholder{color:#a0aec0}input::-ms-input-placeholder,textarea::-ms-input-placeholder{color:#a0aec0}input::placeholder,textarea::placeholder{color:#a0aec0}[role=button],button{cursor:pointer}table{border-collapse:collapse}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}button,input,optgroup,select,textarea{padding:0;line-height:inherit;color:inherit}code,kbd,pre,samp{font-family:Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}.container{width:100%}@media (min-width:640px){.container{max-width:640px}}@media (min-width:768px){.container{max-width:768px}}@media (min-width:1024px){.container{max-width:1024px}}@media (min-width:1280px){.container{max-width:1280px}}.form-input{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:#fff;border-color:#e2e8f0;border-width:1px;border-radius:.25rem;padding:.5rem .75rem;font-size:1rem;line-height:1.5}.form-input::-webkit-input-placeholder{color:#a0aec0;opacity:1}.form-input::-moz-placeholder{color:#a0aec0;opacity:1}.form-input:-ms-input-placeholder{color:#a0aec0;opacity:1}.form-input::-ms-input-placeholder{color:#a0aec0;opacity:1}.form-input::placeholder{color:#a0aec0;opacity:1}.form-input:focus{outline:none;box-shadow:0 0 0 3px rgba(66,153,225,.5);border-color:#63b3ed}.form-textarea{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:#fff;border-color:#e2e8f0;border-width:1px;border-radius:.25rem;padding:.5rem .75rem;font-size:1rem;line-height:1.5}.form-textarea::-webkit-input-placeholder{color:#a0aec0;opacity:1}.form-textarea::-moz-placeholder{color:#a0aec0;opacity:1}.form-textarea:-ms-input-placeholder{color:#a0aec0;opacity:1}.form-textarea::-ms-input-placeholder{color:#a0aec0;opacity:1}.form-textarea::placeholder{color:#a0aec0;opacity:1}.form-textarea:focus{outline:none;box-shadow:0 0 0 3px rgba(66,153,225,.5);border-color:#63b3ed}.form-multiselect{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:#fff;border-color:#e2e8f0;border-width:1px;border-radius:.25rem;padding:.5rem .75rem;font-size:1rem;line-height:1.5}.form-multiselect:focus{outline:none;box-shadow:0 0 0 3px rgba(66,153,225,.5);border-color:#63b3ed}.form-select{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23a0aec0'%3E%3Cpath d='M15.3 9.3a1 1 0 011.4 1.4l-4 4a1 1 0 01-1.4 0l-4-4a1 1 0 011.4-1.4l3.3 3.29 3.3-3.3z'/%3E%3C/svg%3E");-webkit-appearance:none;-moz-appearance:none;appearance:none;-webkit-print-color-adjust:exact;color-adjust:exact;background-repeat:no-repeat;background-color:#fff;border-color:#e2e8f0;border-width:1px;border-radius:.25rem;padding:.5rem 2.5rem .5rem .75rem;font-size:1rem;line-height:1.5;background-position:right .5rem center;background-size:1.5em 1.5em}.form-select::-ms-expand{color:#a0aec0;border:none}@media not print{.form-select::-ms-expand{display:none}}@media print and (-ms-high-contrast:active),print and (-ms-high-contrast:none){.form-select{padding-right:.75rem}}.form-select:focus{outline:none;box-shadow:0 0 0 3px rgba(66,153,225,.5);border-color:#63b3ed}.form-checkbox{-webkit-appearance:none;-moz-appearance:none;appearance:none;-webkit-print-color-adjust:exact;color-adjust:exact;display:inline-block;vertical-align:middle;background-origin:border-box;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;flex-shrink:0;height:1em;width:1em;color:#4299e1;background-color:#fff;border-color:#e2e8f0;border-width:1px;border-radius:.25rem}.form-checkbox:checked{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 16 16' fill='%23fff' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5.707 7.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4a1 1 0 00-1.414-1.414L7 8.586 5.707 7.293z'/%3E%3C/svg%3E");border-color:transparent;background-color:currentColor;background-size:100% 100%;background-position:50%;background-repeat:no-repeat}@media not print{.form-checkbox::-ms-check{border-width:1px;color:transparent;background:inherit;border-color:inherit;border-radius:inherit}}.form-checkbox:focus{outline:none;box-shadow:0 0 0 3px rgba(66,153,225,.5);border-color:#63b3ed}.form-radio{-webkit-appearance:none;-moz-appearance:none;appearance:none;-webkit-print-color-adjust:exact;color-adjust:exact;display:inline-block;vertical-align:middle;background-origin:border-box;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;flex-shrink:0;border-radius:100%;height:1em;width:1em;color:#4299e1;background-color:#fff;border-color:#e2e8f0;border-width:1px}.form-radio:checked{background-image:url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 16 16' fill='%23fff' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='8' cy='8' r='3'/%3E%3C/svg%3E");border-color:transparent;background-color:currentColor;background-size:100% 100%;background-position:50%;background-repeat:no-repeat}@media not print{.form-radio::-ms-check{border-width:1px;color:transparent;background:inherit;border-color:inherit;border-radius:inherit}}.form-radio:focus{outline:none;box-shadow:0 0 0 3px rgba(66,153,225,.5);border-color:#63b3ed}.nav-button,.nav-button-active{padding:.5rem .75rem;border-radius:.375rem;font-size:.875rem;font-weight:500;--text-opacity:1;color:#e2e8f0;color:rgba(226,232,240,var(--text-opacity))}.nav-button-active{background-color:#1a202c;background-color:rgba(26,32,44,var(--bg-opacity))}.nav-button-active,.nav-button-active:focus,.nav-button:focus{--text-opacity:1;color:#fff;color:rgba(255,255,255,var(--text-opacity));--bg-opacity:1}.nav-button-active:focus,.nav-button:focus{outline:0}.nav-button-active:focus,.nav-button:focus,.nav-button:hover{background-color:#4a5568;background-color:rgba(74,85,104,var(--bg-opacity))}.nav-button:hover{--text-opacity:1;color:#fff;color:rgba(255,255,255,var(--text-opacity));--bg-opacity:1}.th{padding:.75rem 1.5rem;--bg-opacity:1;background-color:#f7fafc;background-color:rgba(247,250,252,var(--bg-opacity));text-align:left;font-size:.75rem;line-height:1rem;font-weight:500;--text-opacity:1;color:#a0aec0;color:rgba(160,174,192,var(--text-opacity));text-transform:uppercase;letter-spacing:.05em}.td,.th{border-bottom-width:1px;--border-opacity:1;border-color:#edf2f7;border-color:rgba(237,242,247,var(--border-opacity))}.td{padding:1rem 1.5rem;white-space:nowrap}.btn{font-weight:700;padding:.5rem 1rem;border-radius:.25rem}.btn-blue{--bg-opacity:1;background-color:#4299e1;background-color:rgba(66,153,225,var(--bg-opacity));--text-opacity:1;color:#fff;color:rgba(255,255,255,var(--text-opacity))}.btn-blue:hover{--bg-opacity:1;background-color:#2b6cb0;background-color:rgba(43,108,176,var(--bg-opacity))}.btn-red{--bg-opacity:1;background-color:#f56565;background-color:rgba(245,101,101,var(--bg-opacity));--text-opacity:1;color:#fff;color:rgba(255,255,255,var(--text-opacity))}.btn-red:hover{--bg-opacity:1;background-color:#c53030;background-color:rgba(197,48,48,var(--bg-opacity))}.alert-warning{background-color:#fffaf0;background-color:rgba(255,250,240,var(--bg-opacity));border-left-width:4px;--border-opacity:1;border-color:#ed8936;border-color:rgba(237,137,54,var(--border-opacity));color:#c05621;color:rgba(192,86,33,var(--text-opacity))}.alert-success,.alert-warning{--bg-opacity:1;--text-opacity:1;padding:1rem}.alert-success{background-color:#f0fff4;background-color:rgba(240,255,244,var(--bg-opacity));border-left-width:4px;--border-opacity:1;border-color:#48bb78;border-color:rgba(72,187,120,var(--border-opacity));color:#2f855a;color:rgba(47,133,90,var(--text-opacity))}.alert-error{--bg-opacity:1;background-color:#fff5f5;background-color:rgba(255,245,245,var(--bg-opacity));border-left-width:4px;--border-opacity:1;border-color:#f56565;border-color:rgba(245,101,101,var(--border-opacity));--text-opacity:1;color:#c53030;color:rgba(197,48,48,var(--text-opacity));padding:1rem}.bg-transparent{background-color:transparent}.bg-white{--bg-opacity:1;background-color:#fff;background-color:rgba(255,255,255,var(--bg-opacity))}.bg-gray-200{--bg-opacity:1;background-color:#edf2f7;background-color:rgba(237,242,247,var(--bg-opacity))}.bg-gray-800{--bg-opacity:1;background-color:#2d3748;background-color:rgba(45,55,72,var(--bg-opacity))}.bg-gray-900{--bg-opacity:1;background-color:#1a202c;background-color:rgba(26,32,44,var(--bg-opacity))}.hover\:bg-gray-700:hover{--bg-opacity:1;background-color:#4a5568;background-color:rgba(74,85,104,var(--bg-opacity))}.hover\:bg-blue-500:hover{--bg-opacity:1;background-color:#4299e1;background-color:rgba(66,153,225,var(--bg-opacity))}.focus\:bg-gray-700:focus{--bg-opacity:1;background-color:#4a5568;background-color:rgba(74,85,104,var(--bg-opacity))}.border-gray-200{--border-opacity:1;border-color:#edf2f7;border-color:rgba(237,242,247,var(--border-opacity))}.border-gray-300{--border-opacity:1;border-color:#e2e8f0;border-color:rgba(226,232,240,var(--border-opacity))}.border-red-500{--border-opacity:1;border-color:#f56565;border-color:rgba(245,101,101,var(--border-opacity))}.border-blue-500{--border-opacity:1;border-color:#4299e1;border-color:rgba(66,153,225,var(--border-opacity))}.focus\:border-transparent:focus,.hover\:border-transparent:hover{border-color:transparent}.focus\:border-blue-300:focus{--border-opacity:1;border-color:#90cdf4;border-color:rgba(144,205,244,var(--border-opacity))}.rounded{border-radius:.25rem}.rounded-md{border-radius:.375rem}.rounded-r-md{border-top-right-radius:.375rem;border-bottom-right-radius:.375rem}.rounded-l-md{border-top-left-radius:.375rem;border-bottom-left-radius:.375rem}.border{border-width:1px}.border-t{border-top-width:1px}.border-b{border-bottom-width:1px}.cursor-not-allowed{cursor:not-allowed}.block{display:block}.inline-block{display:inline-block}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.hidden{display:none}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-baseline{align-items:baseline}.self-end{align-self:flex-end}.justify-start{justify-content:flex-start}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.flex-1{flex:1 1 0%}.flex-shrink-0{flex-shrink:0}.font-medium{font-weight:500}.font-semibold{font-weight:600}.font-bold{font-weight:700}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-10{height:2.5rem}.h-16{height:4rem}.text-sm{font-size:.875rem}.text-base{font-size:1rem}.text-3xl{font-size:1.875rem}.leading-5{line-height:1.25rem}.leading-tight{line-height:1.25}.list-inside{list-style-position:inside}.list-disc{list-style-type:disc}.my-2{margin-top:.5rem;margin-bottom:.5rem}.my-4{margin-top:1rem;margin-bottom:1rem}.mx-auto{margin-left:auto;margin-right:auto}.-my-2{margin-top:-.5rem;margin-bottom:-.5rem}.mt-1{margin-top:.25rem}.ml-2{margin-left:.5rem}.mt-4{margin-top:1rem}.mr-4{margin-right:1rem}.mb-4{margin-bottom:1rem}.ml-4{margin-left:1rem}.mr-6{margin-right:1.5rem}.ml-10{margin-left:2.5rem}.-mr-2{margin-right:-.5rem}.-ml-px{margin-left:-1px}.max-w-6xl{max-width:72rem}.min-w-full{min-width:100%}.focus\:outline-none:focus{outline:0}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.p-2{padding:.5rem}.p-4{padding:1rem}.p-8{padding:2rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.px-2{padding-left:.5rem;padding-right:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.px-3{padding-left:.75rem;padding-right:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.px-4{padding-left:1rem;padding-right:1rem}.py-6{padding-top:1.5rem;padding-bottom:1.5rem}.px-6{padding-left:1.5rem;padding-right:1.5rem}.pt-2{padding-top:.5rem}.pb-3{padding-bottom:.75rem}.relative{position:relative}.shadow-sm{box-shadow:0 1px 2px 0 rgba(0,0,0,.05)}.shadow{box-shadow:0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px 0 rgba(0,0,0,.06)}.focus\:shadow-none:focus{box-shadow:none}.text-right{text-align:right}.text-white{--text-opacity:1;color:#fff;color:rgba(255,255,255,var(--text-opacity))}.text-gray-300{--text-opacity:1;color:#e2e8f0;color:rgba(226,232,240,var(--text-opacity))}.text-gray-400{--text-opacity:1;color:#cbd5e0;color:rgba(203,213,224,var(--text-opacity))}.text-gray-500{--text-opacity:1;color:#a0aec0;color:rgba(160,174,192,var(--text-opacity))}.text-gray-600{--text-opacity:1;color:#718096;color:rgba(113,128,150,var(--text-opacity))}.text-gray-700{--text-opacity:1;color:#4a5568;color:rgba(74,85,104,var(--text-opacity))}.text-gray-800{--text-opacity:1;color:#2d3748;color:rgba(45,55,72,var(--text-opacity))}.text-gray-900{--text-opacity:1;color:#1a202c;color:rgba(26,32,44,var(--text-opacity))}.text-red-500{--text-opacity:1;color:#f56565;color:rgba(245,101,101,var(--text-opacity))}.text-red-600{--text-opacity:1;color:#e53e3e;color:rgba(229,62,62,var(--text-opacity))}.text-blue-600{--text-opacity:1;color:#3182ce;color:rgba(49,130,206,var(--text-opacity))}.text-blue-700{--text-opacity:1;color:#2b6cb0;color:rgba(43,108,176,var(--text-opacity))}.hover\:text-white:hover{--text-opacity:1;color:#fff;color:rgba(255,255,255,var(--text-opacity))}.hover\:text-gray-400:hover{--text-opacity:1;color:#cbd5e0;color:rgba(203,213,224,var(--text-opacity))}.hover\:text-gray-700:hover{--text-opacity:1;color:#4a5568;color:rgba(74,85,104,var(--text-opacity))}.hover\:text-red-900:hover{--text-opacity:1;color:#742a2a;color:rgba(116,42,42,var(--text-opacity))}.hover\:text-blue-900:hover{--text-opacity:1;color:#2a4365;color:rgba(42,67,101,var(--text-opacity))}.focus\:text-white:focus{--text-opacity:1;color:#fff;color:rgba(255,255,255,var(--text-opacity))}.align-middle{vertical-align:middle}.whitespace-no-wrap{white-space:nowrap}.w-4{width:1rem}.w-5{width:1.25rem}.w-6{width:1.5rem}.w-auto{width:auto}.w-3\/12{width:25%}.w-4\/12{width:33.333333%}.w-full{width:100%}.z-0{z-index:0}.grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.transition{transition-property:background-color,border-color,color,fill,stroke,opacity,box-shadow,transform}.ease-in-out{transition-timing-function:cubic-bezier(.4,0,.2,1)}.duration-150{transition-duration:.15s}@media (min-width:640px){.sm\:rounded-lg{border-radius:.5rem}.sm\:flex{display:flex}.sm\:items-center{align-items:center}.sm\:justify-end{justify-content:flex-end}.sm\:-mx-6{margin-left:-1.5rem;margin-right:-1.5rem}.sm\:px-0{padding-left:0;padding-right:0}.sm\:px-3{padding-left:.75rem;padding-right:.75rem}.sm\:px-6{padding-left:1.5rem;padding-right:1.5rem}}@media (min-width:768px){.md\:block{display:block}.md\:hidden{display:none}.md\:grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))}}@media (min-width:1024px){.lg\:-mx-8{margin-left:-2rem;margin-right:-2rem}.lg\:px-8{padding-left:2rem;padding-right:2rem}.lg\:px-32{padding-left:8rem;padding-right:8rem}}
--------------------------------------------------------------------------------
/public/mix-manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "/laratrust.css": "/laratrust.css?id=8c7ac59946cfc7c35e3f",
3 | "/img/logo.png": "/img/logo.png?id=b16a11382c0453bdb8a3"
4 | }
5 |
--------------------------------------------------------------------------------
/resources/css/styles.css:
--------------------------------------------------------------------------------
1 | @tailwind base;
2 |
3 | @tailwind components;
4 |
5 | .nav-button,.nav-button-active {
6 | @apply px-3 py-2 rounded-md text-sm font-medium text-gray-300;
7 | }
8 | .nav-button-active {
9 | @apply text-white bg-gray-900;
10 | }
11 |
12 | .nav-button:focus, .nav-button-active:focus {
13 | @apply outline-none text-white bg-gray-700;
14 | }
15 |
16 | .nav-button:hover {
17 | @apply text-white bg-gray-700;
18 | }
19 |
20 | .th {
21 | @apply px-6 py-3 border-b border-gray-200 bg-gray-100 text-left text-xs leading-4 font-medium text-gray-500 uppercase tracking-wider;
22 | }
23 |
24 | .td {
25 | @apply px-6 py-4 whitespace-no-wrap border-b border-gray-200;
26 | }
27 |
28 | .btn {
29 | @apply font-bold py-2 px-4 rounded;
30 | }
31 | .btn-blue {
32 | @apply bg-blue-500 text-white;
33 | }
34 | .btn-blue:hover {
35 | @apply bg-blue-700;
36 | }
37 | .btn-red {
38 | @apply bg-red-500 text-white;
39 | }
40 | .btn-red:hover {
41 | @apply bg-red-700;
42 | }
43 |
44 | .alert-warning {
45 | @apply bg-orange-100 border-l-4 border-orange-500 text-orange-700 p-4;
46 | }
47 |
48 | .alert-success {
49 | @apply bg-green-100 border-l-4 border-green-500 text-green-700 p-4;
50 | }
51 |
52 | .alert-error {
53 | @apply bg-red-100 border-l-4 border-red-500 text-red-700 p-4;
54 | }
55 |
56 | @tailwind utilities;
--------------------------------------------------------------------------------
/resources/views/migration.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | use Illuminate\Database\Migrations\Migration;
5 | use Illuminate\Database\Schema\Blueprint;
6 | use Illuminate\Support\Facades\Schema;
7 |
8 | class LaratrustSetupTables extends Migration
9 | {
10 | /**
11 | * Run the migrations.
12 | *
13 | * @return void
14 | */
15 | public function up()
16 | {
17 | // Create table for storing roles
18 | Schema::create('{{ $laratrust['tables']['roles'] }}', function (Blueprint $table) {
19 | $table->bigIncrements('id');
20 | $table->string('name')->unique();
21 | $table->string('display_name')->nullable();
22 | $table->string('description')->nullable();
23 | $table->timestamps();
24 | });
25 |
26 | // Create table for storing permissions
27 | Schema::create('{{ $laratrust['tables']['permissions'] }}', function (Blueprint $table) {
28 | $table->bigIncrements('id');
29 | $table->string('name')->unique();
30 | $table->string('display_name')->nullable();
31 | $table->string('description')->nullable();
32 | $table->timestamps();
33 | });
34 |
35 | @if ($laratrust['teams']['enabled'])
36 | // Create table for storing teams
37 | Schema::create('{{ $laratrust['tables']['teams'] }}', function (Blueprint $table) {
38 | $table->bigIncrements('id');
39 | $table->string('name')->unique();
40 | $table->string('display_name')->nullable();
41 | $table->string('description')->nullable();
42 | $table->timestamps();
43 | });
44 |
45 | @endif
46 | // Create table for associating roles to users and teams (Many To Many Polymorphic)
47 | Schema::create('{{ $laratrust['tables']['role_user'] }}', function (Blueprint $table) {
48 | $table->unsignedBigInteger('{{ $laratrust['foreign_keys']['role'] }}');
49 | $table->unsignedBigInteger('{{ $laratrust['foreign_keys']['user'] }}');
50 | $table->string('user_type');
51 | @if ($laratrust['teams']['enabled'])
52 | $table->unsignedBigInteger('{{ $laratrust['foreign_keys']['team'] }}')->nullable();
53 | @endif
54 |
55 | $table->foreign('{{ $laratrust['foreign_keys']['role'] }}')->references('id')->on('{{ $laratrust['tables']['roles'] }}')
56 | ->onUpdate('cascade')->onDelete('cascade');
57 | @if ($laratrust['teams']['enabled'])
58 | $table->foreign('{{ $laratrust['foreign_keys']['team'] }}')->references('id')->on('{{ $laratrust['tables']['teams'] }}')
59 | ->onUpdate('cascade')->onDelete('cascade');
60 |
61 | $table->unique(['{{ $laratrust['foreign_keys']['user'] }}', '{{ $laratrust['foreign_keys']['role'] }}', 'user_type', '{{ $laratrust['foreign_keys']['team'] }}']);
62 | @else
63 |
64 | $table->primary(['{{ $laratrust['foreign_keys']['user'] }}', '{{ $laratrust['foreign_keys']['role'] }}', 'user_type']);
65 | @endif
66 | });
67 |
68 | // Create table for associating permissions to users (Many To Many Polymorphic)
69 | Schema::create('{{ $laratrust['tables']['permission_user'] }}', function (Blueprint $table) {
70 | $table->unsignedBigInteger('{{ $laratrust['foreign_keys']['permission'] }}');
71 | $table->unsignedBigInteger('{{ $laratrust['foreign_keys']['user'] }}');
72 | $table->string('user_type');
73 | @if ($laratrust['teams']['enabled'])
74 | $table->unsignedBigInteger('{{ $laratrust['foreign_keys']['team'] }}')->nullable();
75 | @endif
76 |
77 | $table->foreign('{{ $laratrust['foreign_keys']['permission'] }}')->references('id')->on('{{ $laratrust['tables']['permissions'] }}')
78 | ->onUpdate('cascade')->onDelete('cascade');
79 | @if ($laratrust['teams']['enabled'])
80 | $table->foreign('{{ $laratrust['foreign_keys']['team'] }}')->references('id')->on('{{ $laratrust['tables']['teams'] }}')
81 | ->onUpdate('cascade')->onDelete('cascade');
82 |
83 | $table->unique(['{{ $laratrust['foreign_keys']['user'] }}', '{{ $laratrust['foreign_keys']['permission'] }}', 'user_type', '{{ $laratrust['foreign_keys']['team'] }}']);
84 | @else
85 |
86 | $table->primary(['{{ $laratrust['foreign_keys']['user'] }}', '{{ $laratrust['foreign_keys']['permission'] }}', 'user_type']);
87 | @endif
88 | });
89 |
90 | // Create table for associating permissions to roles (Many-to-Many)
91 | Schema::create('{{ $laratrust['tables']['permission_role'] }}', function (Blueprint $table) {
92 | $table->unsignedBigInteger('{{ $laratrust['foreign_keys']['permission'] }}');
93 | $table->unsignedBigInteger('{{ $laratrust['foreign_keys']['role'] }}');
94 |
95 | $table->foreign('{{ $laratrust['foreign_keys']['permission'] }}')->references('id')->on('{{ $laratrust['tables']['permissions'] }}')
96 | ->onUpdate('cascade')->onDelete('cascade');
97 | $table->foreign('{{ $laratrust['foreign_keys']['role'] }}')->references('id')->on('{{ $laratrust['tables']['roles'] }}')
98 | ->onUpdate('cascade')->onDelete('cascade');
99 |
100 | $table->primary(['{{ $laratrust['foreign_keys']['permission'] }}', '{{ $laratrust['foreign_keys']['role'] }}']);
101 | });
102 | }
103 |
104 | /**
105 | * Reverse the migrations.
106 | *
107 | * @return void
108 | */
109 | public function down()
110 | {
111 | Schema::dropIfExists('{{ $laratrust['tables']['permission_user'] }}');
112 | Schema::dropIfExists('{{ $laratrust['tables']['permission_role'] }}');
113 | Schema::dropIfExists('{{ $laratrust['tables']['permissions'] }}');
114 | Schema::dropIfExists('{{ $laratrust['tables']['role_user'] }}');
115 | Schema::dropIfExists('{{ $laratrust['tables']['roles'] }}');
116 | @if ($laratrust['teams']['enabled'])
117 | Schema::dropIfExists('{{ $laratrust['tables']['teams'] }}');
118 | @endif
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/resources/views/panel/edit.blade.php:
--------------------------------------------------------------------------------
1 | @extends('laratrust::panel.layout')
2 |
3 | @section('title', $model ? "Edit {$type}" : "New {$type}")
4 |
5 | @section('content')
6 |