From c068c3ee5035beb60a4b8312d9f21751d587f40c Mon Sep 17 00:00:00 2001 From: Alpet Gexha <50520333+AlpetGexha@users.noreply.github.com> Date: Sun, 25 Jun 2023 21:09:12 +0200 Subject: [PATCH] Add Employee Policy --- app/Filament/Resources/CompanyResource.php | 9 +++++++++ app/Policies/CompanyInvitationPolicy.php | 7 +++++++ app/Policies/EmployeeshipPolicy.php | 7 +++++++ 3 files changed, 23 insertions(+) create mode 100644 app/Policies/CompanyInvitationPolicy.php create mode 100644 app/Policies/EmployeeshipPolicy.php 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 @@ +