Answer the question
In order to leave comments, you need to log in
Is it possible to add provider in if?
Now in the navara the inscription personal cabin is shown. I need it to change to the admin panel for admins. There is a provider that defines a role, but I don't see if it's possible to somehow put it in an if. If there are any other solutions, please let me know.
<ul class="navbar-nav ml-auto">
@guest
<li class="nav-item">
<a class="nav-link" href="{{ route('auth.login') }}">Войти</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('auth.register') }}">Регистрация</a>
</li>
@else
<li class="nav-item">
<a class="nav-link" href="{{ route('user.index') }}">Личный кабинет</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('auth.logout') }}">Выйти</a>
</li>
@endif
@role('web-developer')
<li class="nav-item">
<a class="nav-link" href="{{ route('admin.index') }}">Админ панель</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('auth.logout') }}">Выйти</a>
</li>
@endrole
</ul>
Blade::directive('role', function ($role){
return "<?php if(auth()->check()&& auth()->user()->hasRole({$role})) :?>";
});
Blade::directive('endrole', function ($role){
return "<?php endif; ?>";
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question