53 lines
1.2 KiB
PHP
53 lines
1.2 KiB
PHP
<?php
|
|||
|
|
|
||
|
|
namespace App\Policies;
|
||
|
|
|
||
|
|
use App\Models\Investigation;
|
||
|
|
use App\Models\User;
|
||
|
|
|
||
|
|
class InvestigationPolicy
|
||
|
|
{
|
||
|
|
public function viewAny(User $user): bool
|
||
|
|
{
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function view(User $user, Investigation $investigation): bool
|
||
|
|
{
|
||
|
|
return $investigation->isAccessibleBy($user);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function create(User $user): bool
|
||
|
|
{
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function update(User $user, Investigation $investigation): bool
|
||
|
|
{
|
||
|
|
return $investigation->isEditableBy($user);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function delete(User $user, Investigation $investigation): bool
|
||
|
|
{
|
||
|
|
return $investigation->owner_id === $user->id;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function restore(User $user, Investigation $investigation): bool
|
||
|
|
{
|
||
|
|
return $investigation->owner_id === $user->id;
|
||
|
|
}
|
||
|
|
|
||
|
|
public function forceDelete(User $user, Investigation $investigation): bool
|
||
|
|
{
|
||
|
|
return $investigation->owner_id === $user->id;
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Only the owner can grant/revoke access to users or groups.
|
||
|
|
*/
|
||
|
|
public function manageAccess(User $user, Investigation $investigation): bool
|
||
|
|
{
|
||
|
|
return $investigation->owner_id === $user->id;
|
||
|
|
}
|
||
|
|
}
|