<?php

namespace App\Policies;

use App\Models\PatientFile;
use App\Models\User;

class PatientFilePolicy
{
    public function viewAny(User $user): bool
    {
        return $user->can('files.view');
    }

    public function view(User $user, PatientFile $file): bool
    {
        return $user->can('files.view') && $file->tenant_id === $user->tenant_id;
    }

    public function create(User $user): bool
    {
        return $user->can('files.manage');
    }

    public function update(User $user, PatientFile $file): bool
    {
        return $user->can('files.manage') && $file->tenant_id === $user->tenant_id;
    }

    public function delete(User $user, PatientFile $file): bool
    {
        return $this->update($user, $file);
    }
}
