49 lines
957 B
PHP
49 lines
957 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Policies;
|
|
|
|
use App\Models\PreregistrationPage;
|
|
use App\Models\User;
|
|
|
|
class PreregistrationPagePolicy
|
|
{
|
|
/**
|
|
* Superadmin can do anything — this runs before all other checks.
|
|
*/
|
|
public function before(User $user, string $ability): ?bool
|
|
{
|
|
if ($user->isSuperadmin()) {
|
|
return true;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public function viewAny(User $user): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function view(User $user, PreregistrationPage $page): bool
|
|
{
|
|
return $user->id === $page->user_id;
|
|
}
|
|
|
|
public function create(User $user): bool
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function update(User $user, PreregistrationPage $page): bool
|
|
{
|
|
return $user->id === $page->user_id;
|
|
}
|
|
|
|
public function delete(User $user, PreregistrationPage $page): bool
|
|
{
|
|
return $user->id === $page->user_id;
|
|
}
|
|
}
|