96 lines
2.9 KiB
PHP
96 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\SocialLinks;
|
|
|
|
use App\Filament\Resources\SocialLinks\Pages\ManageSocialLinks;
|
|
use App\Models\SocialLink;
|
|
use BackedEnum;
|
|
use Filament\Actions\BulkActionGroup;
|
|
use Filament\Actions\DeleteAction;
|
|
use Filament\Actions\DeleteBulkAction;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Support\Icons\Heroicon;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Table;
|
|
|
|
class SocialLinkResource extends Resource
|
|
{
|
|
protected static ?string $model = SocialLink::class;
|
|
|
|
protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedShare;
|
|
|
|
protected static ?string $navigationLabel = 'Sosial mediýa';
|
|
|
|
protected static string|\UnitEnum|null $navigationGroup = 'Sahypa mazmunu';
|
|
|
|
protected static ?int $navigationSort = 5;
|
|
|
|
public static function form(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
TextInput::make('platform')
|
|
->label('Platforma')
|
|
->required()
|
|
->placeholder('Instagram'),
|
|
TextInput::make('url')
|
|
->label('URL')
|
|
->required(),
|
|
TextInput::make('icon')
|
|
->label('Material Symbol ikony')
|
|
->required()
|
|
->default('link')
|
|
->placeholder('photo_camera'),
|
|
TextInput::make('sort_order')
|
|
->label('Tertip')
|
|
->required()
|
|
->numeric()
|
|
->default(0),
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('platform')
|
|
->label('Platforma')
|
|
->searchable(),
|
|
TextColumn::make('icon')
|
|
->label('Ikony'),
|
|
TextColumn::make('url')
|
|
->label('URL')
|
|
->searchable(),
|
|
TextColumn::make('sort_order')
|
|
->label('Tertip')
|
|
->numeric()
|
|
->sortable(),
|
|
TextColumn::make('created_at')
|
|
->dateTime()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true),
|
|
])
|
|
->defaultSort('sort_order')
|
|
->filters([])
|
|
->recordActions([
|
|
EditAction::make(),
|
|
DeleteAction::make(),
|
|
])
|
|
->toolbarActions([
|
|
BulkActionGroup::make([
|
|
DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => ManageSocialLinks::route('/'),
|
|
];
|
|
}
|
|
}
|