<?php

namespace App\Policies;

use App\Models\Terminal;
use App\Models\User;

class TerminalPolicy
{
    /**
     * 判断用户是否可以查看终端列表
     *
     * @param User $user
     * @return bool
     */
    public function viewAny(User $user): bool
    {
        return $user->can('terminal.view');
    }

    /**
     * 判断用户是否可以查看特定终端
     *
     * @param User $user
     * @param Terminal $terminal
     * @return bool
     */
    public function view(User $user, Terminal $terminal): bool
    {
        return $user->can('terminal.view');
    }

    /**
     * 判断用户是否可以创建终端
     *
     * @param User $user
     * @return bool
     */
    public function create(User $user): bool
    {
        return $user->can('terminal.create');
    }

    /**
     * 判断用户是否可以更新终端
     *
     * @param User $user
     * @param Terminal $terminal
     * @return bool
     */
    public function update(User $user, Terminal $terminal): bool
    {
        return $user->can('terminal.update');
    }

    /**
     * 判断用户是否可以删除终端
     *
     * @param User $user
     * @param Terminal $terminal
     * @return bool
     */
    public function delete(User $user, Terminal $terminal): bool
    {
        return $user->can('terminal.delete');
    }

    /**
     * 判断用户是否可以恢复已删除的终端
     *
     * @param User $user
     * @param Terminal $terminal
     * @return bool
     */
    public function restore(User $user, Terminal $terminal): bool
    {
        return $user->can('terminal.delete');
    }

    /**
     * 判断用户是否可以永久删除终端
     *
     * @param User $user
     * @param Terminal $terminal
     * @return bool
     */
    public function forceDelete(User $user, Terminal $terminal): bool
    {
        return $user->can('terminal.delete');
    }
}
