Add all files
This commit is contained in:
@@ -0,0 +1,172 @@
|
||||
<?php
|
||||
|
||||
namespace Paymenter\Extensions\Others\ComplianceTools\Admin\Resources;
|
||||
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Infolists\Components\ViewEntry;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables\Table;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Actions\Action as TableAction;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Paymenter\Extensions\Others\ComplianceTools\Admin\Resources\DeletionRequestResource\Pages\ListDeletionRequests;
|
||||
use Paymenter\Extensions\Others\ComplianceTools\Admin\Resources\DeletionRequestResource\Pages\ViewDeletionRequest;
|
||||
use Paymenter\Extensions\Others\ComplianceTools\Models\AccountDeletionRequest;
|
||||
|
||||
class DeletionRequestResource extends Resource
|
||||
{
|
||||
protected static ?string $model = AccountDeletionRequest::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'ri-user-unfollow-line';
|
||||
protected static ?string $activeNavigationIcon = 'ri-user-unfollow-fill';
|
||||
protected static ?string $navigationGroup = 'Compliance';
|
||||
protected static ?string $navigationLabel = 'Deletion Requests';
|
||||
|
||||
protected static bool $shouldRegisterNavigation = true; // Ensure it shows in navigation
|
||||
|
||||
// Ensure Filament can show this resource in the navigation
|
||||
public static function canView(?Model $record = null): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// Forms
|
||||
public static function getFormSchema(): array
|
||||
{
|
||||
return [
|
||||
Textarea::make('admin_notes')->label('Admin Notes'),
|
||||
];
|
||||
}
|
||||
|
||||
// Infolists
|
||||
public static function getInfolistSchema(): array
|
||||
{
|
||||
return [
|
||||
TextEntry::make('client')
|
||||
->label('Client')
|
||||
->state(fn (AccountDeletionRequest $record) => $record?->user?->name ?? '—'),
|
||||
|
||||
TextEntry::make('email')
|
||||
->label('Email')
|
||||
->state(fn (AccountDeletionRequest $record) => $record?->user?->email ?? '—')
|
||||
->copyable(),
|
||||
|
||||
TextEntry::make('status')
|
||||
->label('Status')
|
||||
->badge()
|
||||
->color(fn (AccountDeletionRequest $record) => match ($record->status) {
|
||||
AccountDeletionRequest::STATUS_COMPLETED => 'success',
|
||||
AccountDeletionRequest::STATUS_DENIED => 'danger',
|
||||
AccountDeletionRequest::STATUS_APPROVED => 'warning',
|
||||
default => 'info',
|
||||
}),
|
||||
|
||||
TextEntry::make('reason')
|
||||
->label('Reason')
|
||||
->state(fn (AccountDeletionRequest $record) => $record->reason ?? '—')
|
||||
->columnSpanFull()
|
||||
->extraAttributes(['class' => 'whitespace-pre-wrap']),
|
||||
|
||||
TextEntry::make('requested_at')
|
||||
->label('Requested at')
|
||||
->state(fn (AccountDeletionRequest $record) => optional($record->created_at)?->toDayDateTimeString() ?? '—'),
|
||||
|
||||
TextEntry::make('processed_at')
|
||||
->label('Processed at')
|
||||
->state(fn (AccountDeletionRequest $record) => optional($record->processed_at)?->toDayDateTimeString() ?? '—'),
|
||||
|
||||
TextEntry::make('processed_by')
|
||||
->label('Processed by')
|
||||
->state(fn (AccountDeletionRequest $record) => $record?->processor?->name ?? '—'),
|
||||
|
||||
TextEntry::make('admin_notes')
|
||||
->label('Admin notes')
|
||||
->state(fn (AccountDeletionRequest $record) => $record->admin_notes ?? '—')
|
||||
->columnSpanFull()
|
||||
->extraAttributes(['class' => 'whitespace-pre-wrap']),
|
||||
|
||||
ViewEntry::make('metadata')
|
||||
->label('Request metadata')
|
||||
->view('admin.infolists.components.json')
|
||||
->state(fn (AccountDeletionRequest $record) => $record->metadata)
|
||||
->columnSpanFull(),
|
||||
|
||||
ViewEntry::make('snapshot')
|
||||
->label('Snapshot')
|
||||
->view('admin.infolists.components.json')
|
||||
->state(fn (AccountDeletionRequest $record) => $record->snapshot)
|
||||
->columnSpanFull(),
|
||||
];
|
||||
}
|
||||
|
||||
// Table
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('user.name')
|
||||
->label('Client')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('user.email')
|
||||
->label('Email')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('status')
|
||||
->label('Status')
|
||||
->badge()
|
||||
->color(fn (string $state) => match ($state) {
|
||||
AccountDeletionRequest::STATUS_COMPLETED => 'success',
|
||||
AccountDeletionRequest::STATUS_DENIED => 'danger',
|
||||
AccountDeletionRequest::STATUS_APPROVED => 'warning',
|
||||
default => 'info',
|
||||
})
|
||||
->icon(fn (string $state) => match ($state) {
|
||||
AccountDeletionRequest::STATUS_COMPLETED => 'heroicon-o-check-circle',
|
||||
AccountDeletionRequest::STATUS_DENIED => 'heroicon-o-x-circle',
|
||||
AccountDeletionRequest::STATUS_APPROVED => 'heroicon-o-hand-raised',
|
||||
default => 'heroicon-o-clock',
|
||||
})
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('created_at')
|
||||
->label('Requested')
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('processed_at')
|
||||
->label('Processed')
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('status')
|
||||
->options([
|
||||
AccountDeletionRequest::STATUS_PENDING => 'Pending',
|
||||
AccountDeletionRequest::STATUS_APPROVED => 'Approved',
|
||||
AccountDeletionRequest::STATUS_COMPLETED => 'Completed',
|
||||
AccountDeletionRequest::STATUS_DENIED => 'Denied',
|
||||
]),
|
||||
])
|
||||
->actions([
|
||||
TableAction::make('view')
|
||||
->label('View')
|
||||
->icon('heroicon-o-eye')
|
||||
->url(fn (AccountDeletionRequest $record): string => static::getUrl('view', ['record' => $record]))
|
||||
->visible(fn () => static::getPages()['view'] ?? false),
|
||||
]);
|
||||
}
|
||||
|
||||
// Pages
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListDeletionRequests::route('/'),
|
||||
'view' => ViewDeletionRequest::route('/{record}'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user