Replies: 1 comment
-
I like your idea, but the thing is that in version 3 the Field themselves will not know about Laravel and therefore they will not have access to the Gate inside, in order not to complicate it can be done through a macro, the fields now have a Macroable trait! What do you think about this? You could even organize a package But in general we can implement it abstractly in version 3. In general, we need to think about this, but the idea is excellent. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Feature Description
I propose adding a
checkAbility
method to all Field classes in MoonShine. This method would provide a convenient way to check permissions directly on fields, integrating smoothly with Laravel's authorization system and MoonShine's resource structure.Use Case
When defining fields in a resource, developers often need to check if a user has permission to view or interact with a specific field. Currently, this requires using the
canSee
method with a closure that performs a manual check. A dedicatedcheckAbility
method would simplify this process and make the code more readable and maintainable.Proposed Implementation
Add a
checkAbility
method to the base Field class:Example Usage
This would allow for more intuitive and concise field definitions in resources:
Benefits
Beta Was this translation helpful? Give feedback.
All reactions