Add all files
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
namespace Paymenter\Extensions\Others\ComplianceTools\Admin\Resources;
|
||||
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\BadgeColumn;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Actions\Action;
|
||||
use Paymenter\Extensions\Others\ComplianceTools\Admin\Resources\SupportPinResource\Pages\ListSupportPins;
|
||||
use Paymenter\Extensions\Others\ComplianceTools\Models\SupportPin;
|
||||
|
||||
class SupportPinResource extends Resource
|
||||
{
|
||||
protected static ?string $model = SupportPin::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'ri-key-2-line';
|
||||
protected static ?string $activeNavigationIcon = 'ri-key-2-fill';
|
||||
protected static ?string $navigationGroup = 'Compliance';
|
||||
protected static ?string $navigationLabel = 'Support PINs';
|
||||
|
||||
public static function table(Tables\Table $table): Tables\Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('user.name')
|
||||
->label('Client')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('user.email')
|
||||
->label('Email')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('created_at')
|
||||
->label('Generated')
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
TextColumn::make('expires_at')
|
||||
->label('Expires')
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
TextColumn::make('last_validated_at')
|
||||
->label('Last validated')
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
TextColumn::make('revoked_at')
|
||||
->label('Revoked at')
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
BadgeColumn::make('status')
|
||||
->label('Status')
|
||||
->getStateUsing(fn (SupportPin $record) =>
|
||||
$record->revoked_at ? 'Revoked' : ($record->expires_at->isPast() ? 'Expired' : 'Active')
|
||||
)
|
||||
->colors([
|
||||
'success' => fn ($state) => $state === 'Active',
|
||||
'warning' => fn ($state) => $state === 'Expired',
|
||||
'danger' => fn ($state) => $state === 'Revoked',
|
||||
]),
|
||||
])
|
||||
->filters([
|
||||
Filter::make('active')
|
||||
->label('Active only')
|
||||
->query(fn ($query) => $query->whereNull('revoked_at')->where('expires_at', '>', now())),
|
||||
])
|
||||
->actions([
|
||||
Action::make('revoke')
|
||||
->label('Revoke')
|
||||
->icon('heroicon-o-no-symbol')
|
||||
->color('danger')
|
||||
->requiresConfirmation()
|
||||
->visible(fn (SupportPin $record) => is_null($record->revoked_at) && !$record->expires_at->isPast())
|
||||
->action(fn (SupportPin $record) =>
|
||||
app(\Paymenter\Extensions\Others\ComplianceTools\Services\SupportPinService::class)
|
||||
->revoke($record, auth()->user())
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListSupportPins::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user