Having authorization can
expressions as a property
#986
Unanswered
UltraWelfare
asked this question in
Q&A
Replies: 0 comments
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.
-
I'll be straight to the example since it's a bit easier to grasp:
Properties
slug
,name
are the same as theProperty
model itself.canUpdateStatus
is evaluated with the following expression:auth()->user()->can('updateStatus', $property);
The problem is that I can't use a Computed since I don't have
Property $property
at the constructor. The other thing that I've thought of is manually mapping thecanUpdateStatus
. I'm not sure I quite like this solution because now the mapping doesn't happen centralized. Whenever I'm doing a query to grab a Property and project it to PropertyData, I'd also have to manual-map this field.The "solution" to manual-mapping is kinda not-clean imo, and it needs to be a bit different whether you paginate or get a singular result:
Any ideas?
Beta Was this translation helpful? Give feedback.
All reactions