viewAny = false
policy overrides view
#13157
-
PackageTable builder Package Version3.2.86 How can we help you?I like my users to be able to update their own user info, but not allowed to view/update other users. Is there a way to achieve using policy alone?
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
You could use Laravel Scopes to show records by user public function apply(Builder $builder, Model $model): void
{
$user = auth()->user();
$builder->whereUserId($user->id);
} |
Beta Was this translation helpful? Give feedback.
-
This actually sucks and makes no sense at all.. There is no possibility to show a single record or make a user update a single record without allowing them to view a listing of all records? Filters (globally) will work fine if you can scope them to some parameter in the Model or relationship, but if you use records where you don't have this type of scoping it's not possible.
|
Beta Was this translation helpful? Give feedback.
-
I'm facing the same issue. I have two panels: an admin panel and a client panel. Client registration happens in the admin panel, while in the client panel, they can only view their own profile page. I've already configured both panel providers, and there's nothing wrong with those files. The problem is that viewAny is overriding the view permission when it shouldn't. If viewAny overrides everything, what's the point of having separate permissions?
|
Beta Was this translation helpful? Give feedback.
You could use Laravel Scopes to show records by user