Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

amir441's avatar

Gate Not Working After Changing Authentication to Admin Model

Hi everyone,

I’ve recently changed the authentication system in my Laravel application to use the Admin model instead of the default User model. Everything related to authentication is working fine, but I’m facing an issue with Gate.

Here’s what I’ve done:

In my AppServiceProvider, I defined a simple gate like this:

use Illuminate\Support\Facades\Gate;

public function boot(): void
{
    Gate::define('amir', function () {
        dd('Gate is being evaluated'); // For debugging
        return true;
    });
}

I tried testing the gate using Gate::allows() in a route:

Route::get('/test-gate', function () {
    if (Gate::allows('amir')) {
        return 'Gate passed!';
    }

    return 'Gate denied!';
});

However, the gate never seems to be triggered, and the dd('Gate is being evaluated') inside the closure is not executed.

I suspect it might have something to do with switching the authentication to the Admin model. For context, here’s what I’ve done to switch the authentication model:

Updated config/auth.php to use the Admin model for the web guard:

and this is my Admin.php model

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;

class Admin extends Authenticatable
{
    use HasFactory;

    protected $fillable = [
        'email',
        'password',
    ];
}

How can I fix the gate so that it works with the Admin model?

0 likes
5 replies
Maelfjord's avatar

This may not fix the gate issue but I believe this provider:

'admins' => [
      'driver' => 'eloquent',
      'model' =>  env('AUTH_MODEL', App\Models\Admin::class),
]

is also using the environment file AUTH_MODEL value. If you want the Admin model class to be used, just do:

'admins' => [
      'driver' => 'eloquent',
      'model' =>  App\Models\Admin::class,
]

Please or to participate in this conversation.