Implementa gestão Filament de configurações, serviços, portfólio e depoimentos com policies admin-only, upload validado e seed determinístico. Co-authored-by: Cursor <cursoragent@cursor.com>
77 lines
2.3 KiB
PHP
77 lines
2.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Filament\Resources\PortfolioCases\RelationManagers;
|
|
|
|
use App\Support\PublicImageUploadRules;
|
|
use Filament\Actions\BulkActionGroup;
|
|
use Filament\Actions\CreateAction;
|
|
use Filament\Actions\DeleteAction;
|
|
use Filament\Actions\DeleteBulkAction;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Resources\RelationManagers\RelationManager;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Table;
|
|
|
|
class ImagesRelationManager extends RelationManager
|
|
{
|
|
protected static string $relationship = 'images';
|
|
|
|
protected static ?string $title = 'Galeria';
|
|
|
|
protected static ?string $modelLabel = 'imagem';
|
|
|
|
protected static ?string $pluralModelLabel = 'galeria';
|
|
|
|
public function form(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
PublicImageUploadRules::fileUpload('path', 'Imagem', 'content/portfolio'),
|
|
PublicImageUploadRules::altTextField('alt_text', 'path'),
|
|
TextInput::make('caption')
|
|
->label('Legenda')
|
|
->maxLength(255),
|
|
TextInput::make('sort_order')
|
|
->label('Ordem')
|
|
->numeric()
|
|
->default(0)
|
|
->required(),
|
|
]);
|
|
}
|
|
|
|
public function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->recordTitleAttribute('alt_text')
|
|
->columns([
|
|
TextColumn::make('alt_text')
|
|
->label('Texto alternativo')
|
|
->searchable(),
|
|
TextColumn::make('caption')
|
|
->label('Legenda'),
|
|
TextColumn::make('sort_order')
|
|
->label('Ordem')
|
|
->sortable(),
|
|
])
|
|
->defaultSort('sort_order')
|
|
->reorderable('sort_order')
|
|
->headerActions([
|
|
CreateAction::make(),
|
|
])
|
|
->recordActions([
|
|
EditAction::make(),
|
|
DeleteAction::make()
|
|
->requiresConfirmation(),
|
|
])
|
|
->toolbarActions([
|
|
BulkActionGroup::make([
|
|
DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
}
|