Add this to AppServiceProvider
Blade::directive('hasrole', function ($arguments) {
$roles = explode('|', $arguments);
return "<?php if (auth()->check() && in_array(auth()->user()->role, {$roles})): ?>";
});
Blade::directive('endhasrole', function () {
return '<?php endif; ?>';
});
Then you can use
@hasrole('admin|test')
//
@endhasrole
Or you can use this package https://github.com/spatie/laravel-permission