Let me tell you the points.
- I am using Entrust by https://github.com/Zizaco/entrust/
- I am using multi-auth i.e I have 2 guards as
webforuserstable andadminguard foradminstable. - In
adminstable there are users with multiple permissions (roles too). The
permissionmiddelware has the codeif (!Auth::guard('
admin')->user()->can(explode('|', $permissions)))In my
Adminmodel, I have useduse EntrustUserTrait;Middelware
permissionis working fine onroutes.phpthe only problem I am facing is if anyAdmin Userdoes not have permission supposecan-createthen the html written in the that block should be hidden in blade file.
@permission('can-create')
Lorem Ipsum...
@endpermission
the above blade directives are not highlighted as @if or @foreach etc.
I think there might be something due multi-auth I am using, since Entrust takes users table by default.
Kindly enlighten me, considering this situation.
Yes I got the solution to this issue. Please go through the steps I have used.
php artisan make:provider EntrustCustomServiceProviderapp/Providers/EntrustCustomServiceProvider.phpUse Auth;and Write in thebootfunctionpublic function boot() {
}
Add this entry in providers array in
config/app.php:App\Providers\EntrustCustomServiceProvider::class,One more thing, many of the phpstorm users may wonder why these directives are not auto-populated in the editor then please note, whenever we add custom blade directives, we need to add these in the blade plugin of the phpstorm editor. Here is the solution:
File->settings->php->BladeDefault Settings, go toDirectivestab.+permissionwithout using @, checkhas parameter<?php if (Auth::guard('admin')->user()->can(in prefix and)):?>in suffix@endpermissionwithout adding any parameters.I hope this is helpful for someone like me :)