<?php

namespace App\Domain\Agents\Policies;

use App\Domain\Agents\Models\Agent;
use App\Domain\Identity\Models\User;
use App\Domain\Identity\Services\ScopeGuard;

class AgentPolicy
{
    public function __construct(private readonly ScopeGuard $scopes) {}

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

    public function view(User $user, Agent $agent): bool
    {
        return $user->can('agent.view') && $this->scopes->allows($user, 'agent.view', $agent);
    }

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

    public function update(User $user, Agent $agent): bool
    {
        return $user->can('agent.update') && $this->scopes->allows($user, 'agent.update', $agent);
    }

    public function approve(User $user, Agent $agent): bool
    {
        return $user->can('agent.approve') && $this->scopes->allows($user, 'agent.approve', $agent);
    }

    public function suspend(User $user, Agent $agent): bool
    {
        return $user->can('agent.suspend') && $this->scopes->allows($user, 'agent.suspend', $agent);
    }
}
