Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurpar06 authored and StyleCIBot committed Apr 4, 2024
1 parent 9bbaa95 commit 7b73cb4
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 31 deletions.
47 changes: 22 additions & 25 deletions app/Filament/Resources/ActivityLogResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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([
Expand All @@ -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'),
]),
]);
}
Expand All @@ -74,36 +72,35 @@ 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'),

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([
//
Expand All @@ -121,7 +118,7 @@ public static function getPages(): array
{
return [
'index' => Pages\ListActivityLogs::route('/'),
'view' => Pages\ViewActivityLog::route('/{record}'),
'view' => Pages\ViewActivityLog::route('/{record}'),
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/Models/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions app/Providers/Filament/AdminPanelProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -73,7 +72,7 @@ public function panel(Panel $panel): Panel
FilamentSpatieLaravelBackupPlugin::make()
->usingPage(Backups::class),
])
->bootUsing(function() {
->bootUsing(function () {
activity()->enableLogging();
})
->brandName('phpVMS')
Expand Down
1 change: 0 additions & 1 deletion app/Providers/RouteServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7b73cb4

Please sign in to comment.