Use Policies only for companies Panel, not other

Friends, I have a problem, I am working on a tenancy app with integration of roles and permissions, for the companies panel everything works ok, the problem is that when entering the administration panel the app blocks and does not allow me to view the information, this happens because I am using within the administration panel, the same Model as in Companies, I am referring to the User model, I was looking for an exclusive policy that could be used for said panels, and in chatgpt it suggests this example, but it still doesn't work for me. works.


This is my Policies for Companies Panel

<?php

namespace App\Policies;

use App\Models\User;

class UserPolicy
{
    /**
     * Determine whether the user can view any models.
     */
    public function viewAny(User $user): bool
    {
        return $user->hasRole('Administrador');
    }

}
Was this page helpful?