diff --git a/app/Filament/Pages/ListActivities.php b/app/Filament/Pages/ListActivities.php deleted file mode 100644 index 94ab741..0000000 --- a/app/Filament/Pages/ListActivities.php +++ /dev/null @@ -1,100 +0,0 @@ -user()->isSuperAdmin(), 403); - - $this->record = $this->resolveRecord($record); - } - - public function getTitle(): string - { - return __('filament-activity-log::activities.title', ['record' => $this->getRecordTitle()]); - } - - public function getActivities() - { - return $this->paginateTableQuery( - $this->record->activities()->latest()->getQuery() - ); - } - - public function getFieldLabel(string $name): string - { - static::$fieldLabelMap ??= $this->createFieldLabelMap(); - - return static::$fieldLabelMap[$name] ?? $name; - } - - protected function createFieldLabelMap(): Collection - { - $form = static::getResource()::form(new Form()); - - $components = collect($form->getSchema()); - $extracted = collect(); - - while (($component = $components->shift()) !== null) { - if ($component instanceof Field || $component instanceof MorphToSelect) { - $extracted->push($component); - continue; - } - - $children = $component->getChildComponents(); - - if (count($children) > 0) { - $components = $components->merge($children); - - continue; - } - - $extracted->push($component); - } - - return $extracted - ->filter(fn ($field) => $field instanceof Field) - ->mapWithKeys(fn (Field $field) => [ - $field->getName() => $field->getLabel(), - ]); - } - - protected function getIdentifiedTableQueryStringPropertyNameFor(string $property): string - { - return $property; - } - - protected function getDefaultTableRecordsPerPageSelectOption(): int - { - return 10; - } - - protected function getTableRecordsPerPageSelectOptions(): array - { - return [10, 25, 50]; - } - - protected static function shouldRegisterNavigation(): bool - { - return auth()->user()->isSuperAdmin(); - } -} diff --git a/app/Filament/Resources/CompanyInvitationResource.php b/app/Filament/Resources/CompanyInvitationResource.php index 18419f0..5e212b5 100644 --- a/app/Filament/Resources/CompanyInvitationResource.php +++ b/app/Filament/Resources/CompanyInvitationResource.php @@ -26,17 +26,17 @@ public static function table(Table $table): Table { return $table ->columns([ - Tables\Columns\TextColumn::make('company.name'), Tables\Columns\TextColumn::make('email'), Tables\Columns\TextColumn::make('role'), Tables\Columns\TextColumn::make('created_at') - ->dateTime(), + ->dateTime() + ->sortable(), ]) ->filters([ // ]) ->actions([ - Tables\Actions\EditAction::make(), + // Tables\Actions\EditAction::make(), ]) ->bulkActions([ Tables\Actions\DeleteBulkAction::make(), @@ -55,7 +55,7 @@ public static function getPages(): array return [ 'index' => Pages\ListCompanyInvitations::route('/'), 'create' => Pages\CreateCompanyInvitation::route('/create'), - 'edit' => Pages\EditCompanyInvitation::route('/{record}/edit'), + // 'edit' => Pages\EditCompanyInvitation::route('/{record}/edit'), ]; } } diff --git a/app/Policies/ActivityPolicy.php b/app/Policies/ActivityPolicy.php new file mode 100644 index 0000000..e364a3e --- /dev/null +++ b/app/Policies/ActivityPolicy.php @@ -0,0 +1,133 @@ +isSuperAdmin(); + } + + /** + * Determine whether the user can view the model. + * + * @return \Illuminate\Auth\Access\Response|bool + */ + public function view(User $user) + { + return $user->isSuperAdmin(); + } + + /** + * Determine whether the user can create models. + * + * @return \Illuminate\Auth\Access\Response|bool + */ + public function create(User $user) + { + return $user->isSuperAdmin(); + } + + /** + * Determine whether the user can update the model. + * + * @return \Illuminate\Auth\Access\Response|bool + */ + public function update(User $user, Activity $activity) + { + return $user->isSuperAdmin(); + } + + /** + * Determine whether the user can delete the model. + * + * @return \Illuminate\Auth\Access\Response|bool + */ + public function delete(User $user, Activity $activity) + { + return $user->isSuperAdmin(); + } + + /** + * Determine whether the user can bulk delete. + * + * @return \Illuminate\Auth\Access\Response|bool + */ + public function deleteAny(User $user) + { + return $user->isSuperAdmin(); + } + + /** + * Determine whether the user can permanently delete. + * + * @return \Illuminate\Auth\Access\Response|bool + */ + public function forceDelete(User $user, Activity $activity) + { + return $user->isSuperAdmin(); + } + + /** + * Determine whether the user can permanently bulk delete. + * + * @return \Illuminate\Auth\Access\Response|bool + */ + public function forceDeleteAny(User $user) + { + return $user->isSuperAdmin(); + } + + /** + * Determine whether the user can restore. + * + * @return \Illuminate\Auth\Access\Response|bool + */ + public function restore(User $user, Activity $activity) + { + return $user->isSuperAdmin(); + } + + /** + * Determine whether the user can bulk restore. + * + * @return \Illuminate\Auth\Access\Response|bool + */ + public function restoreAny(User $user) + { + return $user->isSuperAdmin(); + } + + /** + * Determine whether the user can replicate. + * + * @return \Illuminate\Auth\Access\Response|bool + */ + public function replicate(User $user, Activity $activity) + { + return $user->isSuperAdmin(); + } + + /** + * Determine whether the user can reorder. + * + * @return \Illuminate\Auth\Access\Response|bool + */ + public function reorder(User $user) + { + return $user->isSuperAdmin(); + } +} diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index c34a884..cc57bb6 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -31,7 +31,8 @@ class AuthServiceProvider extends ServiceProvider PeriphelPolicy::class => Periphel::class, ProvaiderPolicy::class => Provaider::class, SoftwarePolicy::class => Software::class, - // Activity::class => ActivityPolicy::class, + Activity::class => ActivityPolicy::class + ]; /** diff --git a/app/Traits/HasComapanyId.php b/app/Traits/HasComapanyId.php index fbb2fd6..6014eec 100644 --- a/app/Traits/HasComapanyId.php +++ b/app/Traits/HasComapanyId.php @@ -15,8 +15,8 @@ protected static function bootHasComapanyId() } }); - if (! auth()->user()->isSuperAdmin()) { + // if (auth()->user()) { static::addGlobalScope(new CompanyScope); - } + // } } }