Lets say user_one has permission to view purchase_price
,
and user_two does not have this permission.
I want to dynamically hide the purchase_price
based on the user permission.
What I have done
I already managed the permissions using spatie package.
What I have tried and searched for
I have found that I could use the
boot()
function the model itself to hide certain fields but I don't know how or it is the best solution also it is astatic function
.I could make a
scope
to handle what the API response usingif statements
andselect()
but I don't think this is a good solution too.Also I could use
Laravel resources
.