From b8ba5901d062311da552b44e4ab710fdca19fab2 Mon Sep 17 00:00:00 2001 From: Nasrul Hazim Bin Mohamad Date: Thu, 12 Nov 2020 07:23:24 +0800 Subject: [PATCH] Adding Team Policy Customisation --- 1.x/features/teams.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/1.x/features/teams.md b/1.x/features/teams.md index caded84..37457dd 100644 --- a/1.x/features/teams.md +++ b/1.x/features/teams.md @@ -179,3 +179,26 @@ public function view(User $user, Flight $flight) $user->tokenCan('flight:view'); } ``` + +#### Team Policy Customisation + +If you may want to customise the default Team policy in Jetstream, you can change that in `app/Policies/TeamPolicy.php`. For instance, you have a Laravel Nova installed together with Jetstream. You want to administrate the Teams in your application and you need to changes some of the policy for team to ensure you are able to update the teams in your application: + +```php +/** + * Determine whether the user can update the model. + * + * @return mixed + */ +public function update(User $user, Team $team) +{ + return $user->ownsTeam($team) || ( + ( + request()->is(config('nova.path') . '/*') + || request()->is('nova-api/*') + || request()->is('nova-vendor/*') + ) + && $user->hasRole('superadmin|administrator') + ); +} +```