<?php

namespace App\Policies;

use App\Models\Company;
use App\Models\User;

class CompanyPolicy
{
    /** Antes de cualquier checkeo, super_admin pasa siempre. */
    public function before(User $user): ?bool
    {
        return $user->isSuperAdmin() ? true : null;
    }

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

    public function view(User $user, Company $company): bool
    {
        return $user->company_id === $company->id;
    }

    public function update(User $user, Company $company): bool
    {
        return $user->company_id === $company->id && $user->isCompanyAdmin();
    }

    public function delete(User $user, Company $company): bool
    {
        return false; // Solo super_admin (cubierto por before)
    }
}
