base commit

This commit is contained in:
Mekan1206
2026-07-30 17:24:40 +05:00
commit a794dacd39
345 changed files with 29597 additions and 0 deletions

View File

@@ -0,0 +1,100 @@
<?php
declare(strict_types=1);
namespace App\Filament\Resources\ActivityLogs\Tables;
use App\Models\Bonus;
use App\Models\Department;
use App\Models\DisciplinaryReport;
use App\Models\Employee;
use App\Models\User;
use App\Models\Vacation;
use Filament\Actions\ViewAction;
use Filament\Forms\Components\DatePicker;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Filters\Filter;
use Filament\Tables\Filters\SelectFilter;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
class ActivityLogsTable
{
public static function configure(Table $table): Table
{
return $table
->columns([
TextColumn::make('created_at')
->label('Date')
->dateTime()
->sortable(),
TextColumn::make('description')
->searchable()
->limit(50),
TextColumn::make('event')
->badge()
->searchable()
->sortable(),
TextColumn::make('subject_type')
->label('Subject Type')
->formatStateUsing(fn (?string $state): string => $state ? class_basename($state) : '—')
->searchable()
->sortable(),
TextColumn::make('subject_id')
->label('Subject ID')
->sortable(),
TextColumn::make('causer.name')
->label('Causer')
->searchable()
->sortable(),
TextColumn::make('log_name')
->toggleable(isToggledHiddenByDefault: true),
])
->defaultSort('created_at', 'desc')
->filters([
SelectFilter::make('subject_type')
->label('Subject Type')
->options([
Employee::class => 'Employee',
Vacation::class => 'Vacation',
Bonus::class => 'Bonus',
DisciplinaryReport::class => 'Disciplinary Report',
Department::class => 'Department',
User::class => 'User',
]),
SelectFilter::make('event')
->options(fn (): array => \Spatie\Activitylog\Models\Activity::query()
->whereNotNull('event')
->distinct()
->pluck('event', 'event')
->all()),
SelectFilter::make('causer')
->label('Causer')
->relationship('causer', 'name')
->searchable()
->preload(),
Filter::make('created_at')
->schema([
DatePicker::make('from')
->label('From'),
DatePicker::make('until')
->label('Until'),
])
->query(function (Builder $query, array $data): Builder {
return $query
->when(
$data['from'] ?? null,
fn (Builder $query, string $date): Builder => $query->whereDate('created_at', '>=', $date),
)
->when(
$data['until'] ?? null,
fn (Builder $query, string $date): Builder => $query->whereDate('created_at', '<=', $date),
);
}),
])
->recordActions([
ViewAction::make(),
])
->toolbarActions([]);
}
}