Level 80
@kylym1631 Can you update the formatting of your post? It’s quite difficult to see what you’re asking, and what code you’re trying to show us.
Summer Sale! All accounts are 50% off this week.
This is my company policy view method
public function view(Admin $user, Company $company): bool
{
return $user->hasRole('super-admin') ||
($user->hasRole('manager') && $company->managers()->where('admins.id', $user->id)->exists());
}
I could do like
return $table
->modifyQueryUsing(function (Builder $query): Builder {
return $query->whereHas('managers', function ($query) {
$query->where('admins.id', auth()->id());
});
})
but I would be repeating myself. How can I use the policy view method to query in the table method?
Please or to participate in this conversation.