mapper wip
This commit is contained in:
1 parent
1af6eec5e9
commit
35a6e605b9
4 files changed
+118
-85
No files matched your search
+50
-32
@@ -15,6 +15,7 @@ use Filament\Actions\Action;
|
||||
use Filament\Actions\Concerns\InteractsWithActions;
|
||||
use Filament\Actions\Contracts\HasActions;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Schemas\Components\FusedGroup;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
||||
use Filament\Schemas\Contracts\HasSchemas;
|
||||
@@ -94,41 +95,58 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
|
||||
->defaultPaginationPageOption(10)
|
||||
->filters([
|
||||
Filter::make('events')
|
||||
->columns(4)
|
||||
->schema([
|
||||
Select::make('country_id')
|
||||
->placeholder('Country')
|
||||
->hiddenLabel()
|
||||
->searchable()
|
||||
->preload()
|
||||
->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();
|
||||
FusedGroup::make([
|
||||
Select::make('country_id')
|
||||
->placeholder('Country')
|
||||
->hiddenLabel()
|
||||
->searchable()
|
||||
->preload()
|
||||
->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');
|
||||
})
|
||||
->live()
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('competition_group_id', null);
|
||||
}),
|
||||
Select::make('competition_group_id')
|
||||
->placeholder('League')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->multiple()
|
||||
->searchable()
|
||||
->options(function (Get $get) {
|
||||
return CompetitionGroup::where('sport_id', auth()->user()->sport_id)
|
||||
->whereHas('event', function ($query) {
|
||||
$query->where('starttime', '>', now())
|
||||
->where('betradar_id', 0);
|
||||
})
|
||||
->orderBy('name')
|
||||
->pluck('name', 'id');
|
||||
})
|
||||
->live(),
|
||||
return Country::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id');
|
||||
})
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('competition_group_id', null);
|
||||
})
|
||||
->live(),
|
||||
Select::make('competition_group_id')
|
||||
->placeholder('League')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->searchable()
|
||||
->options(function (Get $get) {
|
||||
$map = Country::all()->pluck('name', 'id');
|
||||
$query = CompetitionGroup::where('sport_id', auth()->user()->sport_id)
|
||||
->whereHas('event', function ($query) {
|
||||
$query->where('starttime', '>', now())
|
||||
->where('betradar_id', 0);
|
||||
});
|
||||
|
||||
if ($get('country_id') ?? null) {
|
||||
$res = $query->where('country_id', $get('country_id'))->get();
|
||||
} else {
|
||||
$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')
|
||||
->columnSpan(2)
|
||||
->displayFormat('d M Y')
|
||||
->columnSpan(2)
|
||||
->minDate(now())
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
@@ -144,7 +162,7 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
|
||||
function (Builder $query, $competition_group_id) {
|
||||
$this->setPage(1);
|
||||
|
||||
return $query->whereIn('competition_group_id', $competition_group_id);
|
||||
return $query->where('competition_group_id', $competition_group_id);
|
||||
}
|
||||
)->when(
|
||||
$data['starttime_period'],
|
||||
|
||||
@@ -13,6 +13,7 @@ use Filament\Actions\Action;
|
||||
use Filament\Actions\Concerns\InteractsWithActions;
|
||||
use Filament\Actions\Contracts\HasActions;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Schemas\Components\FusedGroup;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Concerns\InteractsWithSchemas;
|
||||
use Filament\Schemas\Contracts\HasSchemas;
|
||||
@@ -90,60 +91,64 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
|
||||
->filters([
|
||||
Filter::make('events')
|
||||
->schema([
|
||||
Select::make('country_id')
|
||||
->visible(fn () => in_array(auth()->user()->provider_id, [3, 4]))
|
||||
->placeholder('Country')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->searchable()
|
||||
->preload()
|
||||
// ->multiple()
|
||||
->live()
|
||||
->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();
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('group_id', null);
|
||||
})
|
||||
->placeholder('Country'),
|
||||
Select::make('group_cc')
|
||||
->visible(fn () => auth()->user()->provider_id == 2)
|
||||
->placeholder('Country')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->searchable()
|
||||
->preload()
|
||||
// ->multiple()
|
||||
->live()
|
||||
->options(function () {
|
||||
$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();
|
||||
FusedGroup::make([
|
||||
Select::make('country_id')
|
||||
->visible(fn () => in_array(auth()->user()->provider_id, [3, 4]))
|
||||
->placeholder('Country')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->searchable()
|
||||
->preload()
|
||||
->live()
|
||||
->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();
|
||||
})
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('group_id', null);
|
||||
})
|
||||
->placeholder('Country'),
|
||||
Select::make('group_cc')
|
||||
->visible(fn () => auth()->user()->provider_id == 2)
|
||||
->placeholder('Country')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->searchable()
|
||||
->preload()
|
||||
->live()
|
||||
->options(function (Get $get) {
|
||||
$query = Mapper::query()->where('sport_id', auth()->user()->sport_id)->where('provider_id', auth()->user()->provider_id)->where('starttime', '>', Carbon::now())->groupBy('group_cc');
|
||||
if ($get('country_id') ?? null) {
|
||||
$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');
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('group_id', null);
|
||||
})
|
||||
->placeholder('Country'),
|
||||
Select::make('group_id')
|
||||
->placeholder('League')
|
||||
->label('Leagues')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->searchable()
|
||||
->preload()
|
||||
->multiple()
|
||||
->options(function (Get $get) {
|
||||
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();
|
||||
} 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();
|
||||
} 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();
|
||||
}
|
||||
})
|
||||
->live(),
|
||||
return Country::query()->whereIn('iso2', $res)->pluck('name', 'iso2');
|
||||
})
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('group_id', null);
|
||||
})
|
||||
->placeholder('Country'),
|
||||
Select::make('group_id')
|
||||
->placeholder('League')
|
||||
->label('Leagues')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->searchable()
|
||||
->preload()
|
||||
->multiple()
|
||||
->options(function (Get $get) {
|
||||
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_id'))->groupBy('group_id')->pluck('group', 'group_id')->toArray();
|
||||
} 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();
|
||||
} 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();
|
||||
}
|
||||
})
|
||||
->live(),
|
||||
])->columnSpan(2),
|
||||
DateRangePicker::make('starttime_period')
|
||||
->columnSpan(2)
|
||||
->displayFormat('d M Y')
|
||||
|
||||
@@ -19,6 +19,11 @@ class CompetitionGroup extends Model
|
||||
return $this->belongsTo(Event::class, 'id', 'competition_group_id');
|
||||
}
|
||||
|
||||
public function getFullNameAttribute()
|
||||
{
|
||||
return $this->country->name.' '.$this->name;
|
||||
}
|
||||
|
||||
public function sport()
|
||||
{
|
||||
return $this->belongsTo(Sport::class);
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
#mapper_right .fi-dropdown-list-item,
|
||||
#mapper_left .fi-dropdown-list-item {
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
|
||||
#mapper_right .fi-ta-filter-indicators button,
|
||||
#mapper_left .fi-ta-filter-indicators button {
|
||||
|
||||
Reference in new issue
Block a user