<?php

namespace App\Policies;

use App\Models\TreatmentPlan;
use App\Models\User;

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

    public function view(User $user, TreatmentPlan $plan): bool
    {
        return $user->can('treatment-plans.view') && $plan->tenant_id === $user->tenant_id;
    }

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

    public function update(User $user, TreatmentPlan $plan): bool
    {
        return $user->can('treatment-plans.manage') && $plan->tenant_id === $user->tenant_id;
    }

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