49 lines
1.1 KiB
PHP
49 lines
1.1 KiB
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace App\Policies;
|
|
|
|
use App\Models\Project;
|
|
use App\Models\User;
|
|
|
|
final readonly class ProjectPolicy extends Policy
|
|
{
|
|
public function viewAny(User $user): bool
|
|
{
|
|
return $user->hasPermission('project.view');
|
|
}
|
|
|
|
public function view(User $user, Project $project): bool
|
|
{
|
|
return $user->hasPermission('project.view');
|
|
}
|
|
|
|
public function create(User $user): bool
|
|
{
|
|
return $user->hasPermission('project.create');
|
|
}
|
|
|
|
public function update(User $user, Project $project): bool
|
|
{
|
|
return $user->hasPermission('project.update');
|
|
}
|
|
|
|
public function delete(User $user, Project $project): bool
|
|
{
|
|
return $user->hasPermission('project.delete');
|
|
}
|
|
|
|
public function settingUpAutomaticTranslation(User $user, Project $project): bool
|
|
{
|
|
return $user->hasPermission('project.setting-up-automatic-translation');
|
|
}
|
|
|
|
public function upload(User $user): bool
|
|
{
|
|
if ($user->hasPermission('project.create') || $user->hasPermission('project.update')) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|