38 lines
1.0 KiB
PHP
38 lines
1.0 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace App\Policies;
|
||
|
|
||
|
use App\Invitation;
|
||
|
use App\User;
|
||
|
use Illuminate\Auth\Access\HandlesAuthorization;
|
||
|
use Illuminate\Auth\Access\Response;
|
||
|
|
||
|
class InvitationPolicy
|
||
|
{
|
||
|
use HandlesAuthorization;
|
||
|
|
||
|
public function viewAny(User $user): bool
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
public function view(User $user, Invitation $invitation): Response
|
||
|
{
|
||
|
return $user->can('admin.manageInvitations') ? Response::allow() : Response::deny(__('You do not have permission to view invitations.'));
|
||
|
}
|
||
|
|
||
|
public function create(?User $user): Response
|
||
|
{
|
||
|
if (is_null($user)) {
|
||
|
return Response::allow();
|
||
|
}
|
||
|
|
||
|
return $user->can('admin.manageInvitations') ? Response::allow() : Response::deny(__('You do not have permission to request invitations.'));
|
||
|
}
|
||
|
|
||
|
public function delete(User $user, Invitation $invitation): Response
|
||
|
{
|
||
|
return $user->can('admin.manageInvitations') ? Response::allow() : Response::deny(__('You do not have permission to revoke invitations.'));
|
||
|
}
|
||
|
}
|