<?php
namespace App\Policies;
use App\Models\Evidence;
use App\Models\User;
class EvidencePolicy
{
    public function view(User $user, Evidence $evidence): bool
    {
        if (method_exists($user, 'hasRole') && $user->hasRole('admin')) return true;
        if (method_exists($user, 'hasRole') && $user->hasRole('analyst')) return true;
        return $user->id === $evidence->uploaded_by;
    }
    public function create(User $user): bool
    {
        return method_exists($user, 'hasRole') && ($user->hasRole('admin') || $user->hasRole('investigator') || $user->hasRole('analyst'));
    }
    public function restore(User $user, Evidence $evidence): bool
    {
        return method_exists($user, 'hasRole') && $user->hasRole('admin');
    }
}
