-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@can blade with guard name not working #1290
Comments
+1 |
You cannot pass the guard to |
Anyone solved this issue? |
Nothing to "solve". It's operating by design. |
@AhmedHdeawy, You can create own blade directive like
|
Solved my problem... Thank you bro @AhmedHdeawy AhmedHdeawy @if(auth('admin')->user()->can('admin.users.view')) |
why can't create own blade directive just like @can('','','') |
@auth('admin') Works fine if you admin guard set in your config/auth.php |
Given this problem, I've created a PR to be able to use another blade directive in this case, a little bit more confortable than the whole With this change, you can use the following directive
|
The @can does not work with my custom guard so I changed the default guard to my custom guard, and it worked. |
Did you try |
It worked! I spent 2 days on this issue. Thank you very much for your help! |
Hi, thanks for this awesome package,
i have a problem that is:
i have multiple guards [ 'web', 'admin' ]
in Admin Model i have
protected $guard_name = 'admin';
and i have guard name for each permission in
like the image below
the problem is when use @can directive like:
@can('admin.users.view')
it doesn't work, not show the code that in it, even if this admin is Super Admin or Admin
also when use
@can('admin.users.view', 'admin')
it doesn't work also
but when use
@if(auth('admin')->user()->can('admin.users.view'))
it works fine
how i can use @can only because is simple for code.
thanks in advance
The text was updated successfully, but these errors were encountered: