You've already forked Atomcms-edit
120 lines
3.1 KiB
PHP
Executable File
120 lines
3.1 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Filament\Resources\Atom;
|
|
|
|
use App\Filament\Resources\Atom\NavigationResource\Pages\CreateNavigation;
|
|
use App\Filament\Resources\Atom\NavigationResource\Pages\EditNavigation;
|
|
use App\Filament\Resources\Atom\NavigationResource\Pages\ListNavigations;
|
|
use App\Filament\Resources\Atom\NavigationResource\RelationManagers\SubNavigationsRelationManager;
|
|
use App\Filament\Traits\TranslatableResource;
|
|
use App\Models\WebsiteNavigation;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Table;
|
|
|
|
class NavigationResource extends Resource
|
|
{
|
|
use TranslatableResource;
|
|
|
|
#[\Override]
|
|
protected static ?string $model = WebsiteNavigation::class;
|
|
|
|
#[\Override]
|
|
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-bars-3';
|
|
|
|
#[\Override]
|
|
protected static string|\UnitEnum|null $navigationGroup = 'Website';
|
|
|
|
#[\Override]
|
|
protected static ?string $slug = 'website/navigations';
|
|
|
|
public static string $translateIdentifier = 'navigations';
|
|
|
|
#[\Override]
|
|
public static function form(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components(static::getForm());
|
|
}
|
|
|
|
public static function getForm(): array
|
|
{
|
|
return [
|
|
TextInput::make('name')
|
|
->label(__('Name'))
|
|
->required()
|
|
->maxLength(255),
|
|
|
|
TextInput::make('url')
|
|
->label(__('URL'))
|
|
->required()
|
|
->maxLength(255),
|
|
|
|
TextInput::make('icon')
|
|
->label(__('Icon'))
|
|
->maxLength(255),
|
|
|
|
TextInput::make('order')
|
|
->label(__('Order'))
|
|
->numeric()
|
|
->default(0),
|
|
|
|
Select::make('parent_id')
|
|
->label(__('Parent Navigation'))
|
|
->relationship('parent', 'name')
|
|
->nullable(),
|
|
];
|
|
}
|
|
|
|
#[\Override]
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns(static::getTable());
|
|
}
|
|
|
|
public static function getTable(): array
|
|
{
|
|
return [
|
|
TextColumn::make('id')
|
|
->label(__('ID'))
|
|
->sortable(),
|
|
|
|
TextColumn::make('name')
|
|
->label(__('Name'))
|
|
->searchable(),
|
|
|
|
TextColumn::make('url')
|
|
->label(__('URL')),
|
|
|
|
TextColumn::make('order')
|
|
->label(__('Order'))
|
|
->sortable(),
|
|
|
|
TextColumn::make('parent.name')
|
|
->label(__('Parent')),
|
|
];
|
|
}
|
|
|
|
#[\Override]
|
|
public static function getRelations(): array
|
|
{
|
|
return [
|
|
SubNavigationsRelationManager::class,
|
|
];
|
|
}
|
|
|
|
#[\Override]
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => ListNavigations::route('/'),
|
|
'create' => CreateNavigation::route('/create'),
|
|
'edit' => EditNavigation::route('/{record}/edit'),
|
|
];
|
|
}
|
|
}
|