<?php

namespace App\Policies;

use App\Enums\RoleName;
use App\Models\Project;
use App\Models\User;

class ProjectPolicy
{
    public function viewAny(User $user): bool { return $user->hasRole(RoleName::Customer) || $user->hasPermission('projects.view'); }
    public function view(User $user, Project $project): bool { return $project->user_id === $user->id || $user->hasPermission('projects.view'); }
    public function create(User $user): bool { return $user->hasRole(RoleName::Customer); }
    public function update(User $user, Project $project): bool { return $project->user_id === $user->id || $user->hasPermission('projects.manage'); }
    public function archive(User $user, Project $project): bool { return $this->update($user, $project); }
    public function restore(User $user, Project $project): bool { return $this->update($user, $project); }
    public function delete(User $user, Project $project): bool { return false; }
    public function deleteAny(User $user): bool { return false; }
}
