82 lines
2.3 KiB
PHP
82 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Sports;
|
|
|
|
use App\Filament\Clusters\Maintenance\MaintenanceCluster;
|
|
use App\Filament\Resources\Sports\Pages\ManageSports;
|
|
use App\Models\Sport;
|
|
use BackedEnum;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Tables\Columns\IconColumn;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Columns\ToggleColumn;
|
|
use Filament\Tables\Filters\TernaryFilter;
|
|
use Filament\Tables\Table;
|
|
use UnitEnum;
|
|
|
|
class SportResource extends Resource
|
|
{
|
|
protected static ?string $model = Sport::class;
|
|
|
|
protected static string|BackedEnum|null $navigationIcon = 'lucide-volleyball';
|
|
|
|
protected static ?string $recordTitleAttribute = 'name';
|
|
|
|
protected static ?string $navigationLabel = 'Sport';
|
|
|
|
protected static ?string $pluralLabel = 'Sports';
|
|
|
|
protected static string|UnitEnum|null $navigationGroup = 'Administration';
|
|
|
|
protected static ?string $cluster = MaintenanceCluster::class;
|
|
|
|
public static function form(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
//
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
IconColumn::make('icon')
|
|
->label('')
|
|
->icon(function ($record): string {
|
|
return $record->icon;
|
|
})->color(function ($record): string {
|
|
if ($record->is_active == 1) {
|
|
return 'primary';
|
|
} else {
|
|
return 'gray';
|
|
}
|
|
}),
|
|
TextColumn::make('name'),
|
|
TextColumn::make('bapi'),
|
|
TextColumn::make('bwin'),
|
|
TextColumn::make('b365'),
|
|
TextColumn::make('logi'),
|
|
TextColumn::make('magl'),
|
|
ToggleColumn::make('is_active'),
|
|
])
|
|
->filters([
|
|
TernaryFilter::make('is_active')->default(true),
|
|
]);
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => ManageSports::route('/'),
|
|
];
|
|
}
|
|
|
|
public static function getNavigationBadge(): ?string
|
|
{
|
|
return parent::getEloquentQuery()->count();
|
|
}
|
|
}
|