<?php
namespace App\Policies;
use App\Models\CaseFile;
use App\Models\User;
class CaseFilePolicy
{
    public function view(User $user, CaseFile $caseFile): bool
    {
        if (method_exists($user, 'hasRole') && $user->hasRole('admin')) return true;
        return $user->id === $caseFile->assigned_user_id;
    }
    public function update(User $user, CaseFile $caseFile): bool
    {
        return method_exists($user, 'hasRole') && ($user->hasRole('admin') || $user->hasRole('analyst'));
    }
    public function restore(User $user, CaseFile $caseFile): bool
    {
        return method_exists($user, 'hasRole') && $user->hasRole('admin');
    }
}
