85 lines
2.8 KiB
PHP
85 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources;
|
|
|
|
use App\Filament\Resources\EventCategoryResource\Pages;
|
|
use App\Filament\Resources\EventCategoryResource\RelationManagers;
|
|
use App\Models\EventCategory;
|
|
use Filament\Forms;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Forms\Form;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Tables;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Table;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
|
use Illuminate\Support\Str;
|
|
|
|
class EventCategoryResource extends Resource
|
|
{
|
|
protected static ?string $model = EventCategory::class;
|
|
|
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
|
|
|
protected static ?string $navigationGroup = 'Новости и мероприятия';
|
|
|
|
protected static ?string $pluralLabel = 'Категории';
|
|
|
|
protected static ?string $navigationParentItem = 'Мероприятия';
|
|
|
|
public static function form(Form $form): Form
|
|
{
|
|
return $form
|
|
->schema([
|
|
Forms\Components\Section::make()->schema([
|
|
Forms\Components\Grid::make()->schema([
|
|
Forms\Components\TextInput::make('title')->label('Название категории')->required()
|
|
->live(onBlur: true)
|
|
->afterStateUpdated(function (string $operation, string|null $state, Forms\Set $set) {
|
|
$set('slug', Str::slug($state));
|
|
}),
|
|
TextInput::make('slug')->label('Текстовый идентификатор категории')->unique(ignoreRecord: true)->readOnly()->required(),
|
|
]),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('id')->label('ID')->sortable(),
|
|
TextColumn::make('title')->label('Название')->sortable()->searchable(),
|
|
TextColumn::make('created_at')->label('Дата создания')->sortable(),
|
|
])
|
|
->filters([
|
|
//
|
|
])
|
|
->actions([
|
|
Tables\Actions\EditAction::make(),
|
|
])
|
|
->bulkActions([
|
|
Tables\Actions\BulkActionGroup::make([
|
|
Tables\Actions\DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public static function getRelations(): array
|
|
{
|
|
return [
|
|
//
|
|
];
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => Pages\ListEventCategories::route('/'),
|
|
'create' => Pages\CreateEventCategory::route('/create'),
|
|
'edit' => Pages\EditEventCategory::route('/{record}/edit'),
|
|
];
|
|
}
|
|
}
|