初始化
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function register(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function boot(): void
|
||||
{
|
||||
\Illuminate\Support\Facades\Blade::if('canPerm', function (?string $permission = null) {
|
||||
$user = auth()->user();
|
||||
if (! $user) {
|
||||
return false;
|
||||
}
|
||||
return $permission === null ? $user->role !== 'user' : $user->canPerm($permission);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user