Skip to content
Snippets Groups Projects
Commit 8a192778 authored by Shizuco's avatar Shizuco
Browse files

feat: access to nova only for users with admin/analyst role

parent 4b7d7120
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@
namespace App\Providers;
use App\Models\User;
use Illuminate\Support\Facades\Gate;
use Laravel\Nova\Nova;
use Laravel\Nova\NovaApplicationServiceProvider;
......@@ -26,9 +27,9 @@ public function boot()
protected function routes()
{
Nova::routes()
->withAuthenticationRoutes()
->withPasswordResetRoutes()
->register();
->withAuthenticationRoutes()
->withPasswordResetRoutes()
->register();
}
/**
......@@ -41,10 +42,8 @@ protected function routes()
protected function gate()
{
Gate::define('viewNova', function ($user) {
return in_array($user->email, [
'admin@groupbwt.com',
'shizuco2002@gmail.com'
]);
return in_array($user->email,
User::where('role', 'admin')->orWhere('role', 'analyst')->pluck('email')->all());
});
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment