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.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
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.