I have this opiece of code in the boot of my RoleServiceProvider:
public function boot()
{
Blade::directive('role', function ($role) {
$hasRole = User::find(Auth::id())->hasRole($role);
return "<?php if ( $hasRole ) : ?>";
});
Blade::directive('endrole', function ($role) {
return "<?php endif; ?>";
});
}
The var $hasRole is holding the status: true/false, now i my blade:
@role('user-manager')
hello
@endrole
Looks OK to me, but it is giving me this error:
Facade\Ignition\Exceptions\ViewException syntax error, unexpected ')' (View: C:\wamp64\www\laravel6\packages\users\management\src\View\overview.blade.php)
For some reason I don't know as the code looks fine to me.. Some suggestions?
@role('user-manager') hello @endrolewill the error gone?RoleServiceProviderin$providersarray inconfig/app.phpfile?storage/framework/views(clear this directory first and then go to the page where you use this directive). You echo$hasRolebut the view doesnt know that variable.