mapper wip

This commit is contained in:
salam committed 2026-02-13 13:33:17 +01:00
1 parent 1af6eec5e9
commit 35a6e605b9
4 files changed
+118 -85

No files matched your search

+50 -32
View File
@@ -15,6 +15,7 @@ use Filament\Actions\Action;
use Filament\Actions\Concerns\InteractsWithActions; use Filament\Actions\Concerns\InteractsWithActions;
use Filament\Actions\Contracts\HasActions; use Filament\Actions\Contracts\HasActions;
use Filament\Forms\Components\Select; use Filament\Forms\Components\Select;
use Filament\Schemas\Components\FusedGroup;
use Filament\Schemas\Components\Utilities\Get; use Filament\Schemas\Components\Utilities\Get;
use Filament\Schemas\Concerns\InteractsWithSchemas; use Filament\Schemas\Concerns\InteractsWithSchemas;
use Filament\Schemas\Contracts\HasSchemas; use Filament\Schemas\Contracts\HasSchemas;
@@ -94,41 +95,58 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
->defaultPaginationPageOption(10) ->defaultPaginationPageOption(10)
->filters([ ->filters([
Filter::make('events') Filter::make('events')
->columns(4)
->schema([ ->schema([
Select::make('country_id') FusedGroup::make([
->placeholder('Country') Select::make('country_id')
->hiddenLabel() ->placeholder('Country')
->searchable() ->hiddenLabel()
->preload() ->searchable()
->options(function () { ->preload()
$res = Event::query()->where('sport_id', auth()->user()->sport_id)->where('betradar_id', 0)->where('starttime', '>', Carbon::now())->groupBy('country_id')->pluck('country_id')->toArray(); ->options(function () {
$res = Event::query()->where('sport_id', auth()->user()->sport_id)->where('betradar_id', 0)->where('starttime', '>', Carbon::now())->groupBy('country_id')->pluck('country_id')->toArray();
return Country::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id'); return Country::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id');
}) })
->live() ->afterStateUpdated(function (callable $set) {
->reactive() $set('competition_group_id', null);
->afterStateUpdated(function (callable $set) { })
$set('competition_group_id', null); ->live(),
}), Select::make('competition_group_id')
Select::make('competition_group_id') ->placeholder('League')
->placeholder('League') ->hiddenLabel()
->hiddenLabel() ->label('')
->label('') ->searchable()
->multiple() ->options(function (Get $get) {
->searchable() $map = Country::all()->pluck('name', 'id');
->options(function (Get $get) { $query = CompetitionGroup::where('sport_id', auth()->user()->sport_id)
return CompetitionGroup::where('sport_id', auth()->user()->sport_id) ->whereHas('event', function ($query) {
->whereHas('event', function ($query) { $query->where('starttime', '>', now())
$query->where('starttime', '>', now()) ->where('betradar_id', 0);
->where('betradar_id', 0); });
})
->orderBy('name') if ($get('country_id') ?? null) {
->pluck('name', 'id'); $res = $query->where('country_id', $get('country_id'))->get();
}) } else {
->live(), $res = $query->get();
}
$arr = [];
foreach ($res as $value) {
if (isset($map[$value->country_id])) {
$arr[$value->id] = $map[$value->country_id].' '.$value->name;
} else {
$arr[$value->id] = $value->name;
}
}
asort($arr);
return $arr;
})
->live(),
])->columnSpan(2),
DateRangePicker::make('starttime_period') DateRangePicker::make('starttime_period')
->columnSpan(2)
->displayFormat('d M Y') ->displayFormat('d M Y')
->columnSpan(2)
->minDate(now()) ->minDate(now())
->hiddenLabel() ->hiddenLabel()
->label('') ->label('')
@@ -144,7 +162,7 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
function (Builder $query, $competition_group_id) { function (Builder $query, $competition_group_id) {
$this->setPage(1); $this->setPage(1);
return $query->whereIn('competition_group_id', $competition_group_id); return $query->where('competition_group_id', $competition_group_id);
} }
)->when( )->when(
$data['starttime_period'], $data['starttime_period'],
+58 -53
View File
@@ -13,6 +13,7 @@ use Filament\Actions\Action;
use Filament\Actions\Concerns\InteractsWithActions; use Filament\Actions\Concerns\InteractsWithActions;
use Filament\Actions\Contracts\HasActions; use Filament\Actions\Contracts\HasActions;
use Filament\Forms\Components\Select; use Filament\Forms\Components\Select;
use Filament\Schemas\Components\FusedGroup;
use Filament\Schemas\Components\Utilities\Get; use Filament\Schemas\Components\Utilities\Get;
use Filament\Schemas\Concerns\InteractsWithSchemas; use Filament\Schemas\Concerns\InteractsWithSchemas;
use Filament\Schemas\Contracts\HasSchemas; use Filament\Schemas\Contracts\HasSchemas;
@@ -90,60 +91,64 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
->filters([ ->filters([
Filter::make('events') Filter::make('events')
->schema([ ->schema([
Select::make('country_id') FusedGroup::make([
->visible(fn () => in_array(auth()->user()->provider_id, [3, 4])) Select::make('country_id')
->placeholder('Country') ->visible(fn () => in_array(auth()->user()->provider_id, [3, 4]))
->hiddenLabel() ->placeholder('Country')
->label('') ->hiddenLabel()
->searchable() ->label('')
->preload() ->searchable()
// ->multiple() ->preload()
->live() ->live()
->options(function (Get $get) { ->options(function (Get $get) {
return Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->where('starttime', '>', Carbon::now())->groupBy('country_id')->pluck('country', 'country_id')->toArray(); return Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->where('starttime', '>', Carbon::now())->groupBy('country_id')->pluck('country', 'country_id')->toArray();
}) })
->reactive() ->afterStateUpdated(function (callable $set) {
->afterStateUpdated(function (callable $set) { $set('group_id', null);
$set('group_id', null); })
}) ->placeholder('Country'),
->placeholder('Country'), Select::make('group_cc')
Select::make('group_cc') ->visible(fn () => auth()->user()->provider_id == 2)
->visible(fn () => auth()->user()->provider_id == 2) ->placeholder('Country')
->placeholder('Country') ->hiddenLabel()
->hiddenLabel() ->label('')
->label('') ->searchable()
->searchable() ->preload()
->preload() ->live()
// ->multiple() ->options(function (Get $get) {
->live() $query = Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->where('starttime', '>', Carbon::now())->groupBy('group_cc');
->options(function () { if ($get('country_id') ?? null) {
$res = Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->where('starttime', '>', Carbon::now())->groupBy('group_cc')->pluck('group_cc')->toArray(); $res = $query->where('country_id', $get('country_id'))->pluck('group_cc')->toArray();
} else {
$res = $query->pluck('group_cc')->toArray();
}
return Country::query()->whereIn('iso2', $res)->pluck('name', 'iso2'); return Country::query()->whereIn('iso2', $res)->pluck('name', 'iso2');
}) })
->reactive() ->reactive()
->afterStateUpdated(function (callable $set) { ->afterStateUpdated(function (callable $set) {
$set('group_id', null); $set('group_id', null);
}) })
->placeholder('Country'), ->placeholder('Country'),
Select::make('group_id') Select::make('group_id')
->placeholder('League') ->placeholder('League')
->label('Leagues') ->label('Leagues')
->hiddenLabel() ->hiddenLabel()
->label('') ->label('')
->searchable() ->searchable()
->preload() ->preload()
->multiple() ->multiple()
->options(function (Get $get) { ->options(function (Get $get) {
if ($get('country_id')) { if ($get('country_id')) {
return Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->where('starttime', '>', Carbon::now())->where('country_id', $get('country'))->groupBy('group_id')->pluck('group', 'group_id')->toArray(); return Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->where('starttime', '>', Carbon::now())->where('country_id', $get('country_id'))->groupBy('group_id')->pluck('group', 'group_id')->toArray();
} elseif ($get('group_cc')) { } elseif ($get('group_cc')) {
return Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->where('starttime', '>', Carbon::now())->where('group_cc', $get('group_cc'))->groupBy('group_id')->pluck('group', 'group_id')->toArray(); return Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->where('starttime', '>', Carbon::now())->where('group_cc', $get('group_cc'))->groupBy('group_id')->pluck('group', 'group_id')->toArray();
} else { } else {
return Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->where('starttime', '>', Carbon::now())->groupBy('group_id')->pluck('group', 'group_id')->toArray(); return Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->where('starttime', '>', Carbon::now())->groupBy('group_id')->pluck('group', 'group_id')->toArray();
} }
}) })
->live(), ->live(),
])->columnSpan(2),
DateRangePicker::make('starttime_period') DateRangePicker::make('starttime_period')
->columnSpan(2) ->columnSpan(2)
->displayFormat('d M Y') ->displayFormat('d M Y')
+5
View File
@@ -19,6 +19,11 @@ class CompetitionGroup extends Model
return $this->belongsTo(Event::class, 'id', 'competition_group_id'); return $this->belongsTo(Event::class, 'id', 'competition_group_id');
} }
public function getFullNameAttribute()
{
return $this->country->name.' '.$this->name;
}
public function sport() public function sport()
{ {
return $this->belongsTo(Sport::class); return $this->belongsTo(Sport::class);
+5
View File
@@ -112,6 +112,11 @@ button[wire\:click="resetTableFiltersForm"] {
@apply p-2 border border-gray-200 shadow rounded-md cursor-pointer has-checked:bg-blue-50 has-checked:text-blue-900 dark:has-checked:bg-blue-950 dark:has-checked:text-blue-200 @apply p-2 border border-gray-200 shadow rounded-md cursor-pointer has-checked:bg-blue-50 has-checked:text-blue-900 dark:has-checked:bg-blue-950 dark:has-checked:text-blue-200
} }
#mapper_right .fi-dropdown-list-item,
#mapper_left .fi-dropdown-list-item {
padding: 2px;
}
#mapper_right .fi-ta-filter-indicators button, #mapper_right .fi-ta-filter-indicators button,
#mapper_left .fi-ta-filter-indicators button { #mapper_left .fi-ta-filter-indicators button {