@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use App\Models\Folder;
|
||||
use App\Models\Invitation;
|
||||
use App\Models\Organization;
|
||||
use App\Models\User;
|
||||
|
||||
class InvitationPolicy
|
||||
{
|
||||
/**
|
||||
* Inviting people into a folder or workspace is gated by the inviteable's
|
||||
* own policies.
|
||||
*/
|
||||
public function create(User $user, Organization|Folder $inviteable): bool
|
||||
{
|
||||
if ($inviteable instanceof Folder) {
|
||||
return $user->can('manageShares', $inviteable);
|
||||
}
|
||||
|
||||
return $user->can('manageMembers', $inviteable);
|
||||
}
|
||||
|
||||
/**
|
||||
* The invitation may be revoked by whoever sent it or by an admin of the
|
||||
* thing it invites into.
|
||||
*/
|
||||
public function delete(User $user, Invitation $invitation): bool
|
||||
{
|
||||
return $user->id === $invitation->inviter_id
|
||||
|| $user->can('delete', $invitation->inviteable);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user