Replies: 2 comments 4 replies
-
Another possibility: @can('edit-settings')
<p>You can edit settings.</p>
@deny($message)
<x-alert>{{$message}}</x-alert> {{-- ❌ No way to get the message --}}
@endcan |
Beta Was this translation helpful? Give feedback.
1 reply
-
Is this something that can be handled using a Blade Custom If? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
When using authorization gates or policies in Laravel, we often return a
Response::deny('Some message')
to provide a user-friendly reason for rejection. However, the@can
directive in Blade does not expose this message, making it challenging to display meaningful feedback.Example
Currently, in Blade, we can check for permission but cannot retrieve the denial message:
Workaround
A workaround is to manually call Gate::inspect() to fetch the response:
Proposed Solution
Enhance the
@can
directive to provide access to the denial message. Possible implementations:OR
Would love to hear thoughts on this!
Beta Was this translation helpful? Give feedback.
All reactions