Rework frontend

This commit is contained in:
F4ilji
2025-04-02 18:09:54 +05:00
parent 49072e50c7
commit bd3a4408b1
197 changed files with 9715 additions and 6664 deletions
+80 -21
View File
@@ -6,37 +6,61 @@ use App\Filament\Resources\SliderResource\Pages;
use App\Filament\Resources\SliderResource\RelationManagers;
use App\Models\Slider;
use Filament\Forms;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
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 SliderResource extends Resource
{
protected static ?string $model = Slider::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
protected static ?string $navigationGroup = 'Виджеты';
protected static ?string $navigationLabel = 'Слайдеры';
protected static ?string $modelLabel = 'Слайдер';
protected static ?string $pluralModelLabel = 'Слайдеры';
protected static ?string $navigationIcon = 'heroicon-o-photo';
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Section::make()->schema([
Forms\Components\TextInput::make('title')
->live(onBlur: true)
->afterStateUpdated(function (string $operation, string|null $state, Forms\Set $set) {
$set('slug', Str::slug($state));
})
->label('Заголовок слайдера')
->required(),
TextInput::make('slug')->label('Slug')->unique(ignoreRecord: true)->readOnly()->required(),
Toggle::make('is_active')->default(true)->label('Активный слайдер')->inline(false),
]),
Section::make('Настройки слайдера')
->description('Основные параметры отображения слайдера')
->collapsible()
->schema([
TextInput::make('title')
->label('Название слайдера')
->placeholder('Например: Главный слайдер')
->helperText('Это название будет использоваться в административной панели')
->required()
->maxLength(255)
->live(onBlur: true)
->afterStateUpdated(function (string $operation, string|null $state, Forms\Set $set) {
$set('slug', Str::slug($state));
}),
TextInput::make('slug')
->label('URL-идентификатор')
->helperText('Автоматически генерируется из названия')
->required()
->unique(ignoreRecord: true)
->readOnly()
->maxLength(255),
Toggle::make('is_active')
->label('Активность слайдера')
->helperText('Отключите, чтобы временно скрыть слайдер')
->default(true)
->inline(false)
->onColor('success')
->offColor('danger'),
]),
]);
}
@@ -44,25 +68,60 @@ class SliderResource extends Resource
{
return $table
->columns([
//
TextColumn::make('title')
->label('Название')
->sortable()
->searchable()
->description(fn (Slider $record) => $record->slug),
TextColumn::make('slides_count')
->counts('slides')
->label('Кол-во слайдов')
->badge()
->color(fn (int $state): string => $state > 0 ? 'success' : 'danger'),
TextColumn::make('is_active')
->label('Статус')
->badge()
->color(fn (bool $state): string => $state ? 'success' : 'danger')
->formatStateUsing(fn (bool $state): string => $state ? 'Активен' : 'Неактивен'),
])
->filters([
//
Tables\Filters\SelectFilter::make('is_active')
->label('Статус активности')
->options([
true => 'Активные',
false => 'Неактивные',
]),
])
->actions([
Tables\Actions\EditAction::make(),
Tables\Actions\EditAction::make()
->icon('heroicon-o-pencil')
->tooltip('Редактировать'),
Tables\Actions\Action::make('manage_slides')
->icon('heroicon-o-photo')
->tooltip('Управление слайдами')
->url(fn (Slider $record) => SliderResource::getUrl('edit', ['record' => $record]) . '?activeRelationManager=0'),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
Tables\Actions\DeleteBulkAction::make()
->icon('heroicon-o-trash')
->label('Удалить выбранное'),
]),
]);
])
->emptyStateActions([
Tables\Actions\CreateAction::make()
->label('Создать слайдер'),
])
->defaultSort('title', 'asc');
}
public static function getRelations(): array
{
return [
//
RelationManagers\SlidesRelationManager::class,
];
}
@@ -74,4 +133,4 @@ class SliderResource extends Resource
'edit' => Pages\EditSlider::route('/{record}/edit'),
];
}
}
}