<?php

namespace App\Policies;

use App\Models\Dentist;
use App\Models\User;

class DentistPolicy
{
    public function viewAny(User $user): bool
    {
        return $user->can('appointments.view') || $user->can('staff.manage');
    }

    public function view(User $user, Dentist $dentist): bool
    {
        return $this->viewAny($user) && $dentist->tenant_id === $user->tenant_id;
    }

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

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

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