i'm using nova in a project and i want to give acces to dashboard to admin user only. So i try this according to the doc, but i don't know why it's not working. Anyone can hep me to achieve this ! thank's
method gate of NovaServiceProvider here:
protected function gate()
{
Gate::define('viewNova', function ($user) {
$this->isAdmin($user);
});
}
**here i checked if admin user**
public function isAdmin(User $user)
{
return $user->type == 3 ? true : false;
}
I believe it is because you forgot to return it.
protected function gate()
{
Gate::define('viewNova', function ($user) {
return $this->isAdmin($user); // You need to return
});
}