© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
FilamentF
Filament•2y ago•
1 reply
Jigar D

Tenancy Check in Model Policy

My Policy has the following code:
    public function view(User $user, Model $model): bool
    {
        return $user->hasRole(Roles::SUPER_ADMIN)
            || (Filament::getTenant()->id === $user->tenant_id && $user->model->id == $model->id);
    }
    public function view(User $user, Model $model): bool
    {
        return $user->hasRole(Roles::SUPER_ADMIN)
            || (Filament::getTenant()->id === $user->tenant_id && $user->model->id == $model->id);
    }


Is this the correct way?

I am using PrivateChannel for Broadcasting and Authorization is failing because.
/broadcasting/auth
/broadcasting/auth
isn't aware of the tenant.
Authorization callback does a check if user can view model
$user->can('view', Model::find($id));
$user->can('view', Model::find($id));


Any solution to make this work?
Filament banner
FilamentJoin
A powerful open source UI framework for Laravel • Build and ship admin panels & apps fast with Livewire
20,307Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Tenancy Model Scoping Best Practices
FilamentFFilament / ❓┊help
6mo ago
Tenancy with other packages Model
FilamentFFilament / ❓┊help
13mo ago
Multi tenancy model without owner
FilamentFFilament / ❓┊help
2y ago
same model policy: multiple resources
FilamentFFilament / ❓┊help
2y ago