You've already forked Atomcms-edit
Initial commit
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Hotel\CommandLogs;
|
||||
|
||||
use App\Filament\Resources\Hotel\CommandLogs\Pages\ManageCommandLogs;
|
||||
use App\Filament\Traits\TranslatableResource;
|
||||
use App\Models\CommandLog;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class CommandLogResource extends Resource
|
||||
{
|
||||
use TranslatableResource;
|
||||
|
||||
#[\Override]
|
||||
protected static ?string $model = CommandLog::class;
|
||||
|
||||
#[\Override]
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-chat-bubble-bottom-center-text';
|
||||
|
||||
#[\Override]
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Logs';
|
||||
|
||||
public static string $translateIdentifier = 'command-logs';
|
||||
|
||||
#[\Override]
|
||||
protected static ?string $slug = 'logs/commands';
|
||||
|
||||
#[\Override]
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultSort('timestamp', 'desc')
|
||||
->columns([
|
||||
TextColumn::make('user.username')
|
||||
->label(__('filament::resources.columns.username'))
|
||||
->searchable(),
|
||||
|
||||
TextColumn::make('command')
|
||||
->label(__('filament::resources.columns.command'))
|
||||
->searchable(),
|
||||
|
||||
TextColumn::make('succes')
|
||||
->badge()
|
||||
->color(fn (string $state): string => match ($state) {
|
||||
'yes' => 'primary',
|
||||
'no' => 'warning',
|
||||
default => 'gray',
|
||||
})
|
||||
->label(__('filament::resources.columns.success'))
|
||||
->formatStateUsing(fn (string $state): string => __("filament::resources.options.{$state}")),
|
||||
|
||||
TextColumn::make('timestamp')
|
||||
->label(__('filament::resources.columns.executed_at'))
|
||||
->dateTime('Y-m-d H:i')
|
||||
->searchable(),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('succes')
|
||||
->label(__('filament::resources.filters.success'))
|
||||
->options([
|
||||
'yes' => __('filament::resources.options.yes'),
|
||||
'no' => __('filament::resources.options.no'),
|
||||
]),
|
||||
])
|
||||
->recordActions([])
|
||||
->toolbarActions([]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ManageCommandLogs::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filament\Resources\Hotel\CommandLogs\Pages;
|
||||
|
||||
use App\Filament\Resources\Hotel\CommandLogs\CommandLogResource;
|
||||
use Filament\Resources\Pages\ManageRecords;
|
||||
|
||||
class ManageCommandLogs extends ManageRecords
|
||||
{
|
||||
#[\Override]
|
||||
protected static string $resource = CommandLogResource::class;
|
||||
|
||||
#[\Override]
|
||||
protected function getActions(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function getPrimaryKey(): string
|
||||
{
|
||||
return 'timestamp';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user