<?php

declare(strict_types=1);

namespace App\Policies;

use App\Models\AssetWarranty;
use App\Models\User;

/**
 * Record-level rules for Warranty Management.
 *
 * Viewing, creating, editing and renewing are open to every signed-in user,
 * matching every other reference-data module. Deletion is master-only — a
 * soft delete, restorable, the same as Teams, Locations, Categories,
 * Assets and Employees.
 */
class AssetWarrantyPolicy
{
    public function viewAny(User $actor): bool
    {
        return true;
    }

    public function view(User $actor, AssetWarranty $warranty): bool
    {
        return true;
    }

    public function create(User $actor): bool
    {
        return true;
    }

    public function update(User $actor, AssetWarranty $warranty): bool
    {
        return true;
    }

    public function delete(User $actor, AssetWarranty $warranty): bool
    {
        return $actor->is_master;
    }
}
