You've already forked Atomcms-edit
Initial commit
This commit is contained in:
+142
@@ -0,0 +1,142 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Filament\Resources\RadioBanners;
|
||||
|
||||
use App\Filament\Resources\RadioBanners\Pages\ManageRadioBanners;
|
||||
use App\Models\RadioBanner;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\ImageColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class RadioBannerResource extends Resource
|
||||
{
|
||||
#[\Override]
|
||||
protected static ?string $model = RadioBanner::class;
|
||||
|
||||
#[\Override]
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-photo';
|
||||
|
||||
#[\Override]
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Radio';
|
||||
|
||||
#[\Override]
|
||||
protected static ?string $slug = 'radio/banners';
|
||||
|
||||
#[\Override]
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'DJ Banners';
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function getModelLabel(): string
|
||||
{
|
||||
return 'DJ Banner';
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function getPluralModelLabel(): string
|
||||
{
|
||||
return 'DJ Banners';
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make()
|
||||
->schema([
|
||||
Select::make('user_id')
|
||||
->relationship('user', 'username')
|
||||
->required()
|
||||
->searchable()
|
||||
->label('DJ'),
|
||||
|
||||
FileUpload::make('image_path')
|
||||
->label('Banner Afbeelding')
|
||||
->image()
|
||||
->required()
|
||||
->directory('radio-banners')
|
||||
->maxSize(5120)
|
||||
->helperText('Max 5MB. Aanbevolen formaat: 1200x400px'),
|
||||
|
||||
TextInput::make('title')
|
||||
->label('Titel')
|
||||
->placeholder('Bijv. DJ Remco - Weekend Vibes')
|
||||
->maxLength(255),
|
||||
|
||||
Textarea::make('description')
|
||||
->label('Beschrijving')
|
||||
->placeholder('Beschrijving van de show/DJ')
|
||||
->rows(2),
|
||||
|
||||
TextInput::make('sort_order')
|
||||
->label('Volgorde')
|
||||
->numeric()
|
||||
->default(0)
|
||||
->helperText('Lager nummer = eerder getoond'),
|
||||
|
||||
Toggle::make('is_active')
|
||||
->label('Actief')
|
||||
->default(true),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultSort('sort_order')
|
||||
->columns([
|
||||
ImageColumn::make('image_path')
|
||||
->label('Banner')
|
||||
->height(60),
|
||||
|
||||
TextColumn::make('user.username')
|
||||
->label('DJ')
|
||||
->searchable(),
|
||||
|
||||
TextColumn::make('title')
|
||||
->label('Titel')
|
||||
->searchable(),
|
||||
|
||||
TextColumn::make('sort_order')
|
||||
->label('Volgorde'),
|
||||
|
||||
IconColumn::make('is_active')
|
||||
->label('Actief')
|
||||
->boolean(),
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
DeleteAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ManageRadioBanners::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user