From 7b73cb451a359540e8e568247df80e35535b2098 Mon Sep 17 00:00:00 2001 From: arthurpar06 Date: Thu, 4 Apr 2024 16:16:06 +0000 Subject: [PATCH] Apply fixes from StyleCI --- .../Resources/ActivityLogResource.php | 47 +++++++++---------- .../Pages/ListActivityLogs.php | 1 - .../Pages/ViewActivityLog.php | 1 - app/Models/Role.php | 2 +- app/Providers/Filament/AdminPanelProvider.php | 3 +- app/Providers/RouteServiceProvider.php | 1 - 6 files changed, 24 insertions(+), 31 deletions(-) diff --git a/app/Filament/Resources/ActivityLogResource.php b/app/Filament/Resources/ActivityLogResource.php index fbe394481..72999ca4d 100644 --- a/app/Filament/Resources/ActivityLogResource.php +++ b/app/Filament/Resources/ActivityLogResource.php @@ -10,8 +10,6 @@ use Filament\Resources\Resource; use Filament\Tables; use Filament\Tables\Table; -use Illuminate\Database\Eloquent\Builder; -use Illuminate\Database\Eloquent\SoftDeletingScope; use Spatie\Activitylog\Models\Activity; class ActivityLogResource extends Resource @@ -37,21 +35,21 @@ public static function infolist(Infolist $infolist): Infolist { return $infolist ->schema([ - Infolists\Components\Section::make('Causer Information') - ->schema([ - Infolists\Components\TextEntry::make('causer_type')->formatStateUsing(fn (string $state): string => class_basename($state)), - Infolists\Components\TextEntry::make('causer_id') - ->formatStateUsing(function (Activity $record): string { - if (class_basename($record->causer_type) === 'User') { - return $record->causer_id . ' | ' . $record->causer->name_private; - } - - return $record->causer_id . ' | ' . class_basename($record->causer_type); - }) - ->url(fn (Activity $record): ?string => $record->causer_type === 'App\Models\User' ? UserResource::getUrl('edit', ['record' => $record->causer_id]) : null) - ->label('Causer'), - Infolists\Components\TextEntry::make('created_at')->formatStateUsing(fn (Carbon $state): string => $state->diffForHumans() .' | '. $state->format('d.M'))->label('Caused') - ])->columns(3), + Infolists\Components\Section::make('Causer Information') + ->schema([ + Infolists\Components\TextEntry::make('causer_type')->formatStateUsing(fn (string $state): string => class_basename($state)), + Infolists\Components\TextEntry::make('causer_id') + ->formatStateUsing(function (Activity $record): string { + if (class_basename($record->causer_type) === 'User') { + return $record->causer_id.' | '.$record->causer->name_private; + } + + return $record->causer_id.' | '.class_basename($record->causer_type); + }) + ->url(fn (Activity $record): ?string => $record->causer_type === 'App\Models\User' ? UserResource::getUrl('edit', ['record' => $record->causer_id]) : null) + ->label('Causer'), + Infolists\Components\TextEntry::make('created_at')->formatStateUsing(fn (Carbon $state): string => $state->diffForHumans().' | '.$state->format('d.M'))->label('Caused'), + ])->columns(3), Infolists\Components\Section::make('Subject Information') ->schema([ @@ -64,7 +62,7 @@ public static function infolist(Infolist $infolist): Infolist Infolists\Components\Section::make('Changes') ->schema([ Infolists\Components\ViewEntry::make('changes') - ->view('filament.infolists.entries.activity-fields') + ->view('filament.infolists.entries.activity-fields'), ]), ]); } @@ -74,7 +72,7 @@ public static function table(Table $table): Table return $table ->columns([ Tables\Columns\TextColumn::make('subject_type') - ->formatStateUsing(fn (Activity $record): string => class_basename($record->subject_type).' '. $record->event) + ->formatStateUsing(fn (Activity $record): string => class_basename($record->subject_type).' '.$record->event) ->sortable() ->searchable() ->label('Action'), @@ -82,28 +80,27 @@ public static function table(Table $table): Table Tables\Columns\TextColumn::make('causer_type') ->formatStateUsing(function (Activity $record): string { if (class_basename($record->causer_type) === 'User') { - return $record->causer_id . ' | ' . $record->causer->name_private; + return $record->causer_id.' | '.$record->causer->name_private; } - return $record->causer_id . ' | ' . class_basename($record->causer_type); + return $record->causer_id.' | '.class_basename($record->causer_type); }) ->url(fn (Activity $record): ?string => $record->causer_type === 'App\Models\User' ? UserResource::getUrl('edit', ['record' => $record->causer_id]) : null) ->sortable() ->searchable() ->label('Causer'), - Tables\Columns\TextColumn::make('created_at') ->sortable() ->label('Date') - ->since() + ->since(), ]) ->defaultSort('created_at', 'desc') ->filters([ // ]) ->actions([ - Tables\Actions\ViewAction::make()->color('primary') + Tables\Actions\ViewAction::make()->color('primary'), ]) ->bulkActions([ // @@ -121,7 +118,7 @@ public static function getPages(): array { return [ 'index' => Pages\ListActivityLogs::route('/'), - 'view' => Pages\ViewActivityLog::route('/{record}'), + 'view' => Pages\ViewActivityLog::route('/{record}'), ]; } } diff --git a/app/Filament/Resources/ActivityLogResource/Pages/ListActivityLogs.php b/app/Filament/Resources/ActivityLogResource/Pages/ListActivityLogs.php index ac648dbad..4b77d12ff 100644 --- a/app/Filament/Resources/ActivityLogResource/Pages/ListActivityLogs.php +++ b/app/Filament/Resources/ActivityLogResource/Pages/ListActivityLogs.php @@ -3,7 +3,6 @@ namespace App\Filament\Resources\ActivityLogResource\Pages; use App\Filament\Resources\ActivityLogResource; -use Filament\Actions; use Filament\Resources\Pages\ListRecords; class ListActivityLogs extends ListRecords diff --git a/app/Filament/Resources/ActivityLogResource/Pages/ViewActivityLog.php b/app/Filament/Resources/ActivityLogResource/Pages/ViewActivityLog.php index 3544ff105..9f989a319 100644 --- a/app/Filament/Resources/ActivityLogResource/Pages/ViewActivityLog.php +++ b/app/Filament/Resources/ActivityLogResource/Pages/ViewActivityLog.php @@ -3,7 +3,6 @@ namespace App\Filament\Resources\ActivityLogResource\Pages; use App\Filament\Resources\ActivityLogResource; -use Filament\Actions; use Filament\Resources\Pages\ViewRecord; class ViewActivityLog extends ViewRecord diff --git a/app/Models/Role.php b/app/Models/Role.php index 22b9d4513..ad3c12285 100644 --- a/app/Models/Role.php +++ b/app/Models/Role.php @@ -3,9 +3,9 @@ namespace App\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; -use Spatie\Permission\Models\Role as SpatieRole; use Spatie\Activitylog\LogOptions; use Spatie\Activitylog\Traits\LogsActivity; +use Spatie\Permission\Models\Role as SpatieRole; /** * @property int id diff --git a/app/Providers/Filament/AdminPanelProvider.php b/app/Providers/Filament/AdminPanelProvider.php index 79edf0d1a..e7b43273e 100644 --- a/app/Providers/Filament/AdminPanelProvider.php +++ b/app/Providers/Filament/AdminPanelProvider.php @@ -3,7 +3,6 @@ namespace App\Providers\Filament; use App\Filament\Pages\Backups; -use App\Http\Middleware\EnableActivityLogging; use BezhanSalleh\FilamentShield\FilamentShieldPlugin; use Filament\Http\Middleware\Authenticate; use Filament\Http\Middleware\DisableBladeIconComponents; @@ -73,7 +72,7 @@ public function panel(Panel $panel): Panel FilamentSpatieLaravelBackupPlugin::make() ->usingPage(Backups::class), ]) - ->bootUsing(function() { + ->bootUsing(function () { activity()->enableLogging(); }) ->brandName('phpVMS') diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index 50e8c1462..e25552d27 100755 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -2,7 +2,6 @@ namespace App\Providers; -use App\Http\Middleware\EnableActivityLogging; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Route;