<?php
namespace Pterodactyl\Filament\Resources;
use Filament\Forms\Components\Select;
use Pterodactyl\Filament\Resources\ModResource\Pages;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Pterodactyl\Models\Egg;
use Pterodactyl\Models\Mod;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Textarea;
class ModResource extends Resource
{
protected static ?string $model = Mod::class;
protected static ?string $navigationIcon = 'heroicon-o-document-arrow-down';
protected static ?string $navigationGroup = 'Service Management';
protected static ?int $navigationSort = 5;
public static function form(Form $form): Form
{
return $form
->schema([
TextInput::make('name')
->required()
->maxLength(255),
Textarea::make('description')
->nullable(),
Select::make('eggs')
->multiple()
->options(Egg::query()->pluck('name', 'id'))
->searchable()
->preload()
->afterStateHydrated(function ($state, callable $set) {
if (is_array($state)) {
$set('eggs', array_map('intval', $state));
}
})
->dehydrateStateUsing(
fn ($state) => $state ? array_map('intval', $state) : []
),
Textarea::make('install_script')
->required()
->columnSpanFull(),
Textarea::make('uninstall_script')
->nullable()
->columnSpanFull(),
TextInput::make('docker_image')
->required(),
TextInput::make('entrypoint')
->required(),
]);
}
// table code excluded for conciseness
public static function getPages(): array
{
return [
'index' => Pages\ListMods::route('/'),
'create' => Pages\CreateMod::route('/create'),
'edit' => Pages\EditMod::route('/{record}/edit'),
];
}
}
<?php
namespace Pterodactyl\Filament\Resources;
use Filament\Forms\Components\Select;
use Pterodactyl\Filament\Resources\ModResource\Pages;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Pterodactyl\Models\Egg;
use Pterodactyl\Models\Mod;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Textarea;
class ModResource extends Resource
{
protected static ?string $model = Mod::class;
protected static ?string $navigationIcon = 'heroicon-o-document-arrow-down';
protected static ?string $navigationGroup = 'Service Management';
protected static ?int $navigationSort = 5;
public static function form(Form $form): Form
{
return $form
->schema([
TextInput::make('name')
->required()
->maxLength(255),
Textarea::make('description')
->nullable(),
Select::make('eggs')
->multiple()
->options(Egg::query()->pluck('name', 'id'))
->searchable()
->preload()
->afterStateHydrated(function ($state, callable $set) {
if (is_array($state)) {
$set('eggs', array_map('intval', $state));
}
})
->dehydrateStateUsing(
fn ($state) => $state ? array_map('intval', $state) : []
),
Textarea::make('install_script')
->required()
->columnSpanFull(),
Textarea::make('uninstall_script')
->nullable()
->columnSpanFull(),
TextInput::make('docker_image')
->required(),
TextInput::make('entrypoint')
->required(),
]);
}
// table code excluded for conciseness
public static function getPages(): array
{
return [
'index' => Pages\ListMods::route('/'),
'create' => Pages\CreateMod::route('/create'),
'edit' => Pages\EditMod::route('/{record}/edit'),
];
}
}