99 lines
4.0 KiB
PHP
99 lines
4.0 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Clusters\StaticData\Resources\CompetitonGroupProviders\Tables;
|
|
|
|
use App\Models\AddByMethod;
|
|
use App\Models\Country;
|
|
use App\Models\Provider;
|
|
use App\Models\Sport;
|
|
use Filament\Actions\ActionGroup;
|
|
use Filament\Actions\BulkActionGroup;
|
|
use Filament\Actions\DeleteAction;
|
|
use Filament\Actions\DeleteBulkAction;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Tables\Columns\IconColumn;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Enums\FiltersLayout;
|
|
use Filament\Tables\Filters\SelectFilter;
|
|
use Filament\Tables\Table;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
class CompetitonGroupProvidersTable
|
|
{
|
|
public static function configure(Table $table): Table
|
|
{
|
|
return $table
|
|
->striped()
|
|
->columns([
|
|
IconColumn::make('sport.icon')
|
|
->label('')
|
|
->grow(false)
|
|
->color('primary')
|
|
->width(30)
|
|
->icon(fn ($record) => $record->sport->icon)
|
|
->tooltip(fn ($record) => $record->id)
|
|
->visibleFrom('lg'),
|
|
TextColumn::make('provider.name')->color(fn ($record) => $record->provider->color),
|
|
TextColumn::make('competition_group.country.name')
|
|
->wrap()
|
|
->color('gray')
|
|
->label('Country')
|
|
->icon(fn ($record) => $record->competition_group->country->icon),
|
|
TextColumn::make('competition_group.name')
|
|
->label('Provider')
|
|
->searchable(),
|
|
TextColumn::make('provider_group_id')->label('PrId')->alignCenter(),
|
|
TextColumn::make('id')->label('TxId')->alignCenter(),
|
|
TextColumn::make('name')
|
|
->label('TxOdds')
|
|
->searchable(),
|
|
TextColumn::make('add_by_method.name')
|
|
->color(fn ($record) => $record->add_by_method->color)
|
|
->label('Add By'),
|
|
])->filters([
|
|
SelectFilter::make('sport_id')
|
|
->label('Sport')
|
|
->options(Sport::where('is_active', 1)->pluck('name', 'id')),
|
|
SelectFilter::make('country_id')
|
|
->searchable()
|
|
->label('Country')
|
|
->options(Country::orderBy('name')->pluck('name', 'id'))
|
|
->query(function (Builder $query, array $data) {
|
|
if (blank($data['value'])) {
|
|
return $query;
|
|
}
|
|
|
|
return $query->whereHas('competition_group', function (Builder $query) use ($data) {
|
|
return $query->where('country_id', $data['value']);
|
|
});
|
|
}),
|
|
SelectFilter::make('provider_id')
|
|
->label('Provider')
|
|
->options(Provider::where('color', '!=', null)->pluck('name', 'id')),
|
|
SelectFilter::make('add_by_method_id')
|
|
->label('Provider')
|
|
->options(AddByMethod::pluck('name', 'id')),
|
|
], layout: FiltersLayout::AboveContent)
|
|
->deferFilters(false)
|
|
->recordActions([
|
|
ActionGroup::make([
|
|
EditAction::make(),
|
|
DeleteAction::make()
|
|
->successNotification(
|
|
Notification::make()
|
|
->success()
|
|
->title('Group deleted')
|
|
->body('The provider group has been deleted successfully.'),
|
|
),
|
|
])->iconButton()
|
|
->icon('phosphor-dots-three-vertical'),
|
|
])
|
|
->toolbarActions([
|
|
BulkActionGroup::make([
|
|
DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
}
|