outl1ne / nova-settings

A Laravel Nova tool for editing custom settings using native Nova fields.
MIT License
271 stars 98 forks source link

Readme needs updating for authorization hide / show settings #108

Closed Bryan-Lund closed 2 years ago

Bryan-Lund commented 2 years ago

I tried restricting the users that could see the settings by what was in the readme, but it didn't work. I.e. this bit:

public function tools(): array
{
    return [
        NovaSettings::make()->canSee(fn () => user()->isAdmin()),
    ];
}

I had to put Auth:: in front of the user() like so to get it working. Unless i'm missing something, this should be updated:

public function tools(): array
{
    return [
        NovaSettings::make()->canSee(fn () => Auth::user()->isAdmin()),
    ];
}
kevariable commented 2 years ago

it's general example, doesn't mean you gonna take all of an example

Tarpsvo commented 2 years ago

You can create a helper function user() { return Auth::user(); }. 😉