wip
This commit is contained in:
1 parent
4184acdb8a
commit
8f1aeafe46
10 files changed
+136
-55
No files matched your search
@@ -17,6 +17,7 @@ class BookmakersTable
|
||||
->striped()
|
||||
->recordAction(null)
|
||||
->columns([
|
||||
TextColumn::make('id')->searchable(),
|
||||
TextColumn::make('name')
|
||||
->searchable(),
|
||||
BookmakerIcon::make('icon')->label('Icon'),
|
||||
|
||||
@@ -15,13 +15,16 @@ use App\Filament\Tables\Columns\ColumnTotal;
|
||||
use App\Filament\Tables\Columns\ColumnTotalHt;
|
||||
use App\Filament\Tables\Columns\ColumnTotalQ1;
|
||||
use App\Filament\Tables\Columns\ColumnTq;
|
||||
use App\Filament\Tables\Columns\EventColumn;
|
||||
use App\Filament\Tables\Columns\MatchIds;
|
||||
use App\Models\BettypeUser;
|
||||
use App\Models\CompetitionGroup;
|
||||
use App\Models\Country;
|
||||
use App\Models\Event;
|
||||
use App\Models\EventUserStar;
|
||||
use App\Models\Group;
|
||||
use App\Models\MultilineClient;
|
||||
use App\Models\Sport;
|
||||
use CodeWithKyrian\FilamentDateRange\Forms\Components\DateRangePicker;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
@@ -30,6 +33,7 @@ use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Schemas\Components\Icon;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Support\Enums\FontWeight;
|
||||
use Filament\Support\Enums\VerticalAlignment;
|
||||
@@ -113,19 +117,11 @@ class EventsTable
|
||||
|
||||
TextColumn::make('country.name')
|
||||
->wrap()
|
||||
->hidden(fn () => auth()->user()->sport_id == 5)
|
||||
->color('gray')
|
||||
->label('Event')
|
||||
->icon(fn ($record) => $record->country->icon)
|
||||
->description(fn ($record) => $record->competition_group->name),
|
||||
->icon(fn ($record) => $record->country?->icon),
|
||||
|
||||
TextColumn::make('home.name')
|
||||
->wrap()
|
||||
->searchable()
|
||||
->alignRight(),
|
||||
|
||||
TextColumn::make('away.name')
|
||||
->wrap()
|
||||
->searchable(),
|
||||
EventColumn::make('event'),
|
||||
|
||||
ColumnMl::make('odds_2ways')->bookmakers(self::$multiline_gettype['odds_2ways'] ?? [])
|
||||
->visible(fn () => in_array('odds_2ways', self::$bettype_settings))
|
||||
@@ -218,14 +214,34 @@ class EventsTable
|
||||
->width(190)
|
||||
->label('To Qualify'),
|
||||
|
||||
])->searchable(['id', 'betsapi_id', 'betradar_id', 'bet365_id', 'bwin_id', 'magnig_id', 'magken_id', 'lognig_id', 'logcol_id'])
|
||||
])->searchable(['id', 'home.name', 'away.name', 'betsapi_id', 'betradar_id', 'bet365_id', 'bwin_id', 'magnig_id', 'magken_id', 'lognig_id', 'logcol_id'])
|
||||
->defaultSort('starttime', 'ASC')
|
||||
->extremePaginationLinks()
|
||||
->filters([
|
||||
Filter::make('events')
|
||||
->columns(9)->columnSpan(9)
|
||||
->schema([
|
||||
Select::make(name: 'sport_id')
|
||||
->beforeContent(Icon::make(fn () => auth()->user()->sport->icon))
|
||||
->placeholder('Sport')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->multiple()
|
||||
->searchable()
|
||||
->preload()
|
||||
->options(function () {
|
||||
return Sport::query()->where('is_active', 1)->pluck('name', 'id');
|
||||
})
|
||||
->live()
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('country_id', null);
|
||||
$set('competition_group_id', null);
|
||||
$set('group_id', null);
|
||||
}),
|
||||
Select::make(name: 'country_id')
|
||||
->columnSpan(2)
|
||||
->hidden(fn () => auth()->user()->sport_id == 5)
|
||||
->placeholder('Country')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
@@ -243,6 +259,7 @@ class EventsTable
|
||||
$set('competition_group_id', null);
|
||||
}),
|
||||
Select::make('competition_group_id')
|
||||
->hidden(fn () => auth()->user()->sport_id == 5)
|
||||
->columnSpan(2)
|
||||
->placeholder('League')
|
||||
->hiddenLabel()
|
||||
@@ -264,8 +281,31 @@ class EventsTable
|
||||
return $arr;
|
||||
})
|
||||
->live(),
|
||||
DateRangePicker::make('starttime_period')
|
||||
Select::make('group_id')
|
||||
->columnSpan(2)
|
||||
->visible(fn () => auth()->user()->sport_id == 5)
|
||||
->placeholder('Tournament')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->multiple()
|
||||
->searchable()
|
||||
->options(function (Get $get) {
|
||||
if ($get('country_id')) {
|
||||
$res = Event::with('country')->with('group')->where('country_id', $get('country_id'))->where('starttime', '>', Carbon::now())->groupBy('group_id')->get();
|
||||
} else {
|
||||
$res = Event::with('country')->with('group')->where('starttime', '>', Carbon::now())->groupBy('group_id')->get();
|
||||
}
|
||||
$arr = [];
|
||||
foreach ($res as $val) {
|
||||
$arr[$val->group_id] = $val->country?->name.' '.$val->group->name;
|
||||
}
|
||||
asort($arr);
|
||||
|
||||
return $arr;
|
||||
})
|
||||
->live(),
|
||||
DateRangePicker::make('starttime_period')
|
||||
->columnSpan(4)
|
||||
->displayFormat('d M Y')
|
||||
->minDate(now())
|
||||
->hiddenLabel()
|
||||
@@ -281,6 +321,9 @@ class EventsTable
|
||||
->when(
|
||||
$data['country_id'],
|
||||
fn (Builder $query, $country_id) => $query->where('country_id', $country_id)
|
||||
)->when(
|
||||
$data['group_id'],
|
||||
fn (Builder $query, $group_id) => $query->whereIn('group_id', $group_id)
|
||||
)->when(
|
||||
$data['competition_group_id'],
|
||||
fn (Builder $query, $competition_group_id) => $query->whereIn('competition_group_id', $competition_group_id)
|
||||
@@ -319,6 +362,15 @@ class EventsTable
|
||||
}
|
||||
}
|
||||
|
||||
if ($data['group_id'] ?? null) {
|
||||
$group_ids = Group::whereIn('id', $data['group_id'])->pluck('name')->toArray();
|
||||
if (count($group_ids) > 1) {
|
||||
$indicators[] = Indicator::make('Tournament: '.implode(', ', $group_ids))->removeField('group_id');
|
||||
} else {
|
||||
$indicators[] = Indicator::make('Tournaments: '.$group_ids[0])->removeField('group_id');
|
||||
}
|
||||
}
|
||||
|
||||
if ($data['competition_group_id'] ?? null) {
|
||||
$competition_groups = CompetitionGroup::whereIn('id', $data['competition_group_id'])->pluck('name')->toArray();
|
||||
if (count($competition_groups) > 1) {
|
||||
@@ -347,9 +399,8 @@ class EventsTable
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
})
|
||||
->columns(2)->columnSpan(2),
|
||||
], layout: FiltersLayout::Modal)
|
||||
}),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
->persistFiltersInSession()
|
||||
->recordActions([
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Tables\Columns;
|
||||
|
||||
use Filament\Tables\Columns\Column;
|
||||
|
||||
class EventColumn extends Column
|
||||
{
|
||||
protected string $view = 'filament.tables.columns.event-column';
|
||||
}
|
||||
Reference in new issue
Block a user