Stelle das U0-Fundament mit CMS, Mitgliedern und Filament bereit.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
89b35ac480
commit
2035c46edd
130 files changed
+18519
-50
No files matched your search
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\NavigationItems;
|
||||
|
||||
use App\Domain\Cms\NavigationItem;
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Filament\Resources\NavigationItems\Pages\ManageNavigationItems;
|
||||
use Closure;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class NavigationItemResource extends Resource
|
||||
{
|
||||
protected static ?string $model = NavigationItem::class;
|
||||
|
||||
protected static ?string $navigationLabel = 'Navigation';
|
||||
|
||||
protected static ?string $modelLabel = 'Navigationspunkt';
|
||||
|
||||
protected static ?string $pluralModelLabel = 'Navigation';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([
|
||||
TextInput::make('label')->label('Beschriftung')->required()->maxLength(80),
|
||||
Select::make('page_id')
|
||||
->label('Seite')
|
||||
->options(fn (): array => Page::query()->orderBy('path')->pluck('path', 'id')->all())
|
||||
->searchable(),
|
||||
TextInput::make('url')
|
||||
->label('Adresse')
|
||||
->maxLength(500)
|
||||
->rule(function (Get $get): Closure {
|
||||
return function (string $attribute, mixed $value, Closure $fail) use ($get): void {
|
||||
if (blank($get('page_id')) && blank($value)) {
|
||||
$fail('Wählen Sie eine Seite oder eine Adresse.');
|
||||
}
|
||||
};
|
||||
}),
|
||||
Select::make('placement')
|
||||
->label('Platz')
|
||||
->options([
|
||||
'header' => 'Kopfzeile',
|
||||
'footer' => 'Fußzeile',
|
||||
])
|
||||
->required(),
|
||||
TextInput::make('sort_order')->label('Reihenfolge')->numeric()->required()->default(0),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('label')->label('Beschriftung'),
|
||||
TextColumn::make('page.path')->label('Seite'),
|
||||
TextColumn::make('url')->label('Adresse'),
|
||||
TextColumn::make('placement')->label('Platz'),
|
||||
TextColumn::make('sort_order')->label('Reihenfolge')->sortable(),
|
||||
])
|
||||
->defaultSort('sort_order');
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ManageNavigationItems::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user