use Blade::if
to check if a user is admin
This commit is contained in:
parent
556f8268f3
commit
3df2f2dda9
@ -2,9 +2,11 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Blade;
|
||||
use Event;
|
||||
use Utils;
|
||||
use App\Events;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
@ -61,5 +63,9 @@ class AppServiceProvider extends ServiceProvider
|
||||
|
||||
$this->app->singleton('users', \App\Services\Repositories\UserRepository::class);
|
||||
$this->app->singleton('parsedown', \Parsedown::class);
|
||||
|
||||
Blade::if('admin', function (User $user) {
|
||||
return $user->isAdmin();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
<img src="{{ avatar($user, 128) }}" alt="User Image">
|
||||
<p>{{ $user->email }}</p>
|
||||
</li>
|
||||
@if ($user->isAdmin())
|
||||
@admin($user)
|
||||
<!-- Menu Body -->
|
||||
<li class="user-body">
|
||||
<div class="row">
|
||||
@ -34,7 +34,7 @@
|
||||
</div>
|
||||
</li>
|
||||
<style>li.user-header { height: initial !important; }</style>
|
||||
@endif
|
||||
@endadmin
|
||||
<!-- Menu Footer-->
|
||||
<li class="user-footer">
|
||||
<div class="pull-left">
|
||||
|
@ -68,10 +68,10 @@
|
||||
<li class="header">{{ trans('general.explore') }}</li>
|
||||
<li><a href="{{ url('skinlib') }}"><i class="fa fa-archive"></i> <span>{{ trans('general.skinlib') }}</span></a></li>
|
||||
|
||||
@if ($user->isAdmin())
|
||||
@admin($user)
|
||||
<li class="header">{{ trans('general.manage') }}</li>
|
||||
<li><a href="{{ url('admin') }}"><i class="fa fa-cog"></i> <span>{{ trans('general.admin-panel') }}</span></a></li>
|
||||
@endif
|
||||
@endadmin
|
||||
</ul><!-- /.sidebar-menu -->
|
||||
</section>
|
||||
<!-- /.sidebar -->
|
||||
|
Loading…
Reference in New Issue
Block a user