104 lines
3.2 KiB
PHP
104 lines
3.2 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\TimelineEntries;
|
|
|
|
use App\Filament\Resources\TimelineEntries\Pages\ManageTimelineEntries;
|
|
use App\Models\TimelineEntry;
|
|
use BackedEnum;
|
|
use Filament\Actions\BulkActionGroup;
|
|
use Filament\Actions\DeleteAction;
|
|
use Filament\Actions\DeleteBulkAction;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Forms\Components\Textarea;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Support\Icons\Heroicon;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Table;
|
|
|
|
class TimelineEntryResource extends Resource
|
|
{
|
|
protected static ?string $model = TimelineEntry::class;
|
|
|
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedClock;
|
|
|
|
protected static ?string $navigationLabel = 'Taryh';
|
|
|
|
protected static string|\UnitEnum|null $navigationGroup = 'Sahypa mazmunu';
|
|
|
|
protected static ?int $navigationSort = 3;
|
|
|
|
public static function form(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
TextInput::make('year')
|
|
->label('Ýyly')
|
|
->required()
|
|
->numeric()
|
|
->minValue(1900)
|
|
->maxValue(2100),
|
|
TextInput::make('title')
|
|
->label('Başlyk')
|
|
->required(),
|
|
TextInput::make('icon')
|
|
->label('Material Symbol ikony')
|
|
->required()
|
|
->default('history')
|
|
->placeholder('storefront'),
|
|
TextInput::make('sort_order')
|
|
->label('Tertip')
|
|
->required()
|
|
->numeric()
|
|
->default(0),
|
|
Textarea::make('body')
|
|
->label('Tekst')
|
|
->required()
|
|
->rows(3)
|
|
->columnSpanFull(),
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('year')
|
|
->label('Ýyly')
|
|
->sortable(),
|
|
TextColumn::make('title')
|
|
->label('Başlyk')
|
|
->searchable(),
|
|
TextColumn::make('icon')
|
|
->label('Ikony'),
|
|
TextColumn::make('sort_order')
|
|
->label('Tertip')
|
|
->numeric()
|
|
->sortable(),
|
|
TextColumn::make('created_at')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
])
|
|
->defaultSort('sort_order')
|
|
->filters([])
|
|
->recordActions([
|
|
EditAction::make(),
|
|
DeleteAction::make(),
|
|
])
|
|
->toolbarActions([
|
|
BulkActionGroup::make([
|
|
DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => ManageTimelineEntries::route('/'),
|
|
];
|
|
}
|
|
}
|