owner_id === $user->id) { return true; } $subuser = $server->subusers->where('user_id', $user->id)->first(); // If the user is a subuser check their permissions if ($subuser && in_array($ability, $subuser->permissions)) { return true; } // Return null to let default policies take over return null; } /** * This is a horrendous hack to avoid Laravel's "smart" behavior that does * not call the before() function if there isn't a function matching the * policy permission. */ public function __call(string $name, mixed $arguments): void { // do nothing } }