<?php

declare(strict_types=1);

namespace App\Policies;

use App\Models\Position;
use App\Models\User;
use App\Policies\Concerns\ScopedByDepartment;

class PositionPolicy
{
    use ScopedByDepartment;

    public function viewAny(User $user): bool
    {
        if ($this->isSuperAdmin($user)) {
            return true;
        }

        return $this->canRead($user);
    }

    public function view(User $user, Position $position): bool
    {
        if ($this->isSuperAdmin($user)) {
            return true;
        }

        return $this->canRead($user);
    }

    public function create(User $user): bool
    {
        if ($this->isSuperAdmin($user)) {
            return true;
        }

        return $this->hasFullAccess($user);
    }

    public function update(User $user, Position $position): bool
    {
        if ($this->isSuperAdmin($user)) {
            return true;
        }

        return $this->hasFullAccess($user);
    }

    public function delete(User $user, Position $position): bool
    {
        if ($this->isSuperAdmin($user)) {
            return true;
        }

        return $this->hasFullAccess($user);
    }

    public function restore(User $user, Position $position): bool
    {
        if ($this->isSuperAdmin($user)) {
            return true;
        }

        return $this->hasFullAccess($user);
    }

    public function forceDelete(User $user, Position $position): bool
    {
        if ($this->isSuperAdmin($user)) {
            return true;
        }

        return $this->canForceDelete($user);
    }
}
