You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NOTE: Those changes must be made before performing the migration. If you have already run the migration and want to upgrade your solution, you can run the artisan console command `php artisan permission:setup-teams`, to create a new migration file named [xxxx_xx_xx_xx_add_teams_fields.php](https://github.com/spatie/laravel-permission/blob/master/database/migrations/add_teams_fields.php.stub) and then run `php artisan migrate` to upgrade your database tables.
7
+
8
+
When enabled, teams permissions offers you a flexible control for a variety of scenarios. The idea behind teams permissions is inspired by the default permission implementation of [Laratrust](https://laratrust.santigarcor.me/).
9
+
10
+
11
+
Teams permissions can be enabled in the permission config file:
12
+
13
+
```php
14
+
// config/permission.php
15
+
'teams' => true,
16
+
```
17
+
18
+
Also, if you want to use a custom foreign key for teams you must change in the permission config file:
19
+
```php
20
+
// config/permission.php
21
+
'team_foreign_key' => 'custom_team_id',
22
+
```
23
+
24
+
## Working with Teams Permissions
25
+
26
+
After implements on login a solution for select a team on authentication (for example set `team_id` of the current selected team on **session**: `session(['team_id' => $team->team_id]);` ),
27
+
we can set global `team_id` from anywhere, but works better if you create a `Middleware`, example:
Copy file name to clipboardExpand all lines: docs/installation-laravel.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,6 +33,7 @@ This package can be used with Laravel 6.0 or higher.
33
33
```
34
34
35
35
6. NOTE: If you are using UUIDs, see the Advanced section of the docs on UUID steps, before you continue. It explains some changes you may want to make to the migrations and config file before continuing. It also mentions important considerations after extending this package's models for UUID capability.
36
+
If you are going to use teams feature, you have to update your [`config/permission.php` config file](https://github.com/spatie/laravel-permission/blob/master/config/permission.php) and set `'teams' => true,`, if you want to use a custom foreign key for teams you must change `team_foreign_key`.
36
37
37
38
7. Clear your config cache. This package requires access to the `permission` config. Generally it's bad practice to do config-caching in a development environment. If you've been caching configurations locally, clear your config cache with either of these commands:
Ensure the application's database name/credentials are set in your `.env` (or `config/database.php` if you have one), and that the database exists.
54
54
55
+
NOTE: If you are going to use teams feature, you have to update your [`config/permission.php` config file](https://github.com/spatie/laravel-permission/blob/master/config/permission.php) and set `'teams' => true,`, if you want to use a custom foreign key for teams you must change `team_foreign_key`.
56
+
55
57
Run the migrations to create the tables for this package:
0 commit comments