Closed chriswest101 closed 3 years ago
Heya!
If you mean per field, the fields use the canSee
callbacks for authorization.
See the docs here: https://nova.laravel.com/docs/3.0/resources/authorization.html#fields
Example:
Text::make('Name')
->canSee(function ($request) {
return $request->user()->can('viewProfile', $this);
}),
This runs when everything has already booted and you have access to the session and user.
If you want to hide the whole Settings items, you can call ->canSee on the tool in NovaServiceProvider@tools
, like so:
(new \OptimistDigital\NovaSettings\NovaSettings())
->canSee(function($request) {
return $request->user()->isAdmin();
}),
Hope this helps. Good luck!
How can you authorise the user per a setting in the provider boot method when Laravel hasn't loaded the user or session?