diff --git a/app/Filament/Resources/CompanyResource.php b/app/Filament/Resources/CompanyResource.php index 2cb3f2a..10528e7 100644 --- a/app/Filament/Resources/CompanyResource.php +++ b/app/Filament/Resources/CompanyResource.php @@ -9,6 +9,8 @@ use Filament\Resources\Resource; use Filament\Resources\Table; use Filament\Tables; +use Illuminate\Contracts\Database\Query\Builder; +use Illuminate\Database\Eloquent\Builder as EloquentBuilder; class CompanyResource extends Resource { @@ -80,4 +82,11 @@ public static function getPages(): array // 'edit' => Pages\EditCompany::route('/{record}/edit'), ]; } + public static function getEloquentQuery(): EloquentBuilder + { + if (!auth()->user()->isSuperAdmin()) + return parent::getEloquentQuery()->where('id', auth()->user()->current_company_id); + + return parent::getEloquentQuery(); + } } diff --git a/app/Policies/CompanyInvitationPolicy.php b/app/Policies/CompanyInvitationPolicy.php new file mode 100644 index 0000000..5729882 --- /dev/null +++ b/app/Policies/CompanyInvitationPolicy.php @@ -0,0 +1,7 @@ +