mapper new

This commit is contained in:
salam committed 2026-01-20 08:33:20 +01:00
1 parent fe7fc0accf
commit e27bba1644
12 files changed
+179 -107

No files matched your search

@@ -25,25 +25,25 @@ class GenerateDefaultSetting
Notice::note('1) multiline bookmaker slots for client', 'p');
}
$sports = Sport::where('is_active', 1)->get();
$sports = Sport::where('is_active', 1)->pluck('id');
$bookmaker = [0, 6, 30, 649, 117];
$bookmaker_slots = [1 => 6, 2 => 30, 3 => 649, 4 => 126];
$clients = Client::get();
$clients = Client::get()->pluck('id');
foreach ($clients as $client) {
foreach ($clients as $client_id) {
foreach ($sports as $sport) {
foreach ($sports as $sport_id) {
$multilines = MultilineSetting::where('sport_id', $sport->id)->get();
$multilines = MultilineSetting::where('sport_id', $sport_id)->get()->pluck('id');
foreach ($multilines as $multiline) {
foreach ($multilines as $multiline_id) {
for ($slot = 1; $slot <= 4; $slot++) {
foreach ($bookmaker_slots as $slot => $bookmaker_id) {
MultilineClient::updateOrInsert(
['client_id' => $client->id, 'sport_id' => $client->id, 'multiline_setting_id' => $multiline->id, 'position' => $slot],
['bookmaker_id' => $bookmaker[$slot], 'sort' => $slot, 'disabled' => 0]
MultilineClient::firstOrCreate(
['client_id' => $client_id, 'sport_id' => $sport_id, 'multiline_setting_id' => $multiline_id, 'position' => $slot],
['bookmaker_id' => $bookmaker_id, 'sort' => $slot, 'disabled' => 0]
);
}
}
@@ -57,14 +57,13 @@ class EventsTable
public static function load_multiline_bookmaker()
{
$res = MultilineClient::with('multiline_setting')
->where('client_id', auth()->user()->client_id)
->where('sport_id', auth()->user()->sport_id)
->select('bookmaker_id', 'multiline_setting_id')
->orderBy('sort')
->get();
foreach ($res as $value) {
self::$multiline_gettype[$value->multiline_setting->table][] = $value->bookmaker_id;
$table = $value->multiline_setting->table;
self::$multiline_gettype[$table][] = (int) $value->bookmaker_id;
}
}
@@ -214,10 +213,10 @@ class EventsTable
->extremePaginationLinks()
->filters([
Filter::make('events')
->columns(9)->columnSpan(9)
->columns(5)->columnSpan(5)
->schema([
Select::make(name: 'sport_id')
->default(auth()->user()->id)
->default(auth()->user()->sport_id)
->prefixIcon(auth()->user()->sport->icon)
->selectablePlaceholder(false)
->hiddenLabel()
@@ -239,7 +238,6 @@ class EventsTable
}),
Select::make(name: 'country_id')
->columnSpan(2)
->hidden(fn () => auth()->user()->sport_id == 5)
->placeholder('Country')
->hiddenLabel()
@@ -259,7 +257,6 @@ class EventsTable
}),
Select::make('competition_group_id')
->hidden(fn () => auth()->user()->sport_id == 5)
->columnSpan(2)
->placeholder('League')
->hiddenLabel()
->label('')
@@ -281,7 +278,6 @@ class EventsTable
})
->live(),
Select::make('group_id')
->columnSpan(2)
->visible(fn () => auth()->user()->sport_id == 5)
->placeholder('Tournament')
->hiddenLabel()
@@ -304,7 +300,7 @@ class EventsTable
})
->live(),
DateRangePicker::make('starttime_period')
->columnSpan(4)
->columnSpan(2)
->displayFormat('d M Y')
->minDate(now())
->hiddenLabel()
-4
View File
@@ -21,12 +21,9 @@ class LoadEvents
}
})->pluck('id')->toArray();
// dd(Auth::user()->sport_id);
$query = Event::query()
->with('home')
->with('away')
->where('sport_id', Auth::user()->sport_id)
->where('starttime', '>', Carbon::now())
->where(function ($query) use ($element_ids) {
$query->orWhereIn('home_id', $element_ids)->orWhereIn('away_id', $element_ids);
@@ -37,7 +34,6 @@ class LoadEvents
->with('home')
->with('away')
->where('betradar_id', 0)
->where('sport_id', Auth::user()->sport_id)
->where('starttime', '>', Carbon::now());
}
+2 -5
View File
@@ -4,7 +4,6 @@ namespace App\Livewire\Mapper;
use App\Models\Mapper;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Auth;
class LoadProvider
{
@@ -15,9 +14,8 @@ class LoadProvider
$searchValues = preg_split('/\s+/', $search_right, -1, PREG_SPLIT_NO_EMPTY);
return Mapper::query()
->where('sport_id', Auth::user()->sport_id)
->where('starttime', '>', Carbon::now())
->where('provider_id', Auth::user()->provider_id)
->where('provider_id', auth()->user()->provider_id)
->where(function ($query) use ($searchValues) {
foreach ($searchValues as $value) {
$query->orWhere('home', 'LIKE', '%'.$value.'%')
@@ -26,9 +24,8 @@ class LoadProvider
});
} else {
return Mapper::query()
->where('sport_id', Auth::user()->sport_id)
->where('starttime', '>', Carbon::now())
->where('provider_id', Auth::user()->provider_id);
->where('provider_id', auth()->user()->provider_id);
}
}
}
+40 -16
View File
@@ -9,6 +9,7 @@ use App\Models\CompetitionGroup;
use App\Models\Country;
use App\Models\Event;
use App\Models\Mapper;
use App\Models\Sport;
use Carbon\Carbon;
use Filament\Actions\Action;
use Filament\Actions\Concerns\InteractsWithActions;
@@ -74,24 +75,44 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
->filters([
Filter::make('events')
->schema([
Select::make('country_id')
->placeholder('Country')
Select::make(name: 'sport_id')
->default(auth()->user()->sport_id)
->prefixIcon(auth()->user()->sport->icon)
->selectablePlaceholder(false)
->hiddenLabel()
->multiple()
->label('')
->columnSpan(2)
->searchable()
->preload()
->options(function () {
$res = Event::query()->where('betradar_id', 0)->where('starttime', '>', Carbon::now())->groupBy('country_id')->pluck('country_id')->toArray();
return Country::query()->whereIn('id', $res)->pluck('name', 'id');
return Sport::query()->where('is_active', 1)->pluck('name', 'id');
})
->live()
->reactive()
->afterStateUpdated(function (callable $set) {
->afterStateUpdated(function (callable $set, $livewire) {
$livewire->dispatch('reload_data_left');
$livewire->dispatch('reload_data_right');
$set('country_id', null);
$set('competition_group_id', null);
}),
// Select::make('country_id')
// ->placeholder('Country')
// ->hiddenLabel()
// ->multiple()
// ->columnSpan(2)
// ->searchable()
// ->preload()
// ->options(function (Get $get) {
// $res = Event::query()->where('sport_id', $get('sport_id'))->where('betradar_id', 0)->where('starttime', '>', Carbon::now())->groupBy('country_id')->pluck('country_id')->toArray();
// return Country::query()->whereIn('id', $res)->pluck('name', 'id');
// })
// ->live()
// ->reactive()
// ->afterStateUpdated(function (callable $set) {
// $set('competition_group_id', null);
// }),
Select::make('competition_group_id')
->placeholder('League')
->hiddenLabel()
@@ -100,11 +121,11 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
->multiple()
->searchable()
->options(function (Get $get) {
if ($get('country_id')) {
$res = Event::query()->where('betradar_id', 0)->where('starttime', '>', Carbon::now())->whereIn('country_id', $get('country_id'))->groupBy('competition_group_id')->pluck('competition_group_id')->toArray();
} else {
$res = Event::query()->where('betradar_id', 0)->where('starttime', '>', Carbon::now())->groupBy('competition_group_id')->pluck('competition_group_id')->toArray();
}
// if ($get('country_id')) {
// $res = Event::query()->where('sport_id', $get('sport_id'))->where('betradar_id', 0)->where('starttime', '>', Carbon::now())->whereIn('country_id', $get('country_id'))->groupBy('competition_group_id')->pluck('competition_group_id')->toArray();
// } else {
// }
$res = Event::query()->where('sport_id', $get('sport_id'))->where('betradar_id', 0)->where('starttime', '>', Carbon::now())->groupBy('competition_group_id')->pluck('competition_group_id')->toArray();
$comps = CompetitionGroup::with('country')->whereIn('id', $res)->get();
@@ -125,8 +146,11 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
->query(function (Builder $query, array $data): Builder {
return $query
->when(
$data['country_id'],
fn (Builder $query, $country_id) => $query->where('country_id', $country_id)
$data['sport_id'],
fn (Builder $query, $sport_id) => $query->where('sport_id', $sport_id)
// )->when(
// $data['country_id'],
// fn (Builder $query, $country_id) => $query->where('country_id', $country_id)
)->when(
$data['competition_group_id'],
fn (Builder $query, $competition_group_id) => $query->whereIn('competition_group_id', $competition_group_id)
+70 -43
View File
@@ -8,6 +8,7 @@ use App\Livewire\Mapper\StoreMapped;
use App\Models\Country;
use App\Models\Event;
use App\Models\Mapper;
use App\Models\Sport;
use Filament\Actions\Action;
use Filament\Actions\Concerns\InteractsWithActions;
use Filament\Actions\Contracts\HasActions;
@@ -73,44 +74,66 @@ 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')
Select::make(name: 'sport_id')
->default(auth()->user()->sport_id)
->prefixIcon(auth()->user()->sport->icon)
->selectablePlaceholder(false)
->hiddenLabel()
->label('')
->searchable()
->preload()
->multiple()
->columnSpan(2)
->live()
->preload()
->options(function () {
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 Sport::query()->where('is_active', 1)->pluck('name', 'id');
})
->live()
->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()
->columnSpan(2)
->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();
->afterStateUpdated(function (callable $set, $livewire) {
return Country::query()->whereIn('iso2', $res)->pluck('name', 'iso2');
})
->reactive()
->afterStateUpdated(function (callable $set) {
$livewire->dispatch('reload_data_left');
$livewire->dispatch('reload_data_right');
// $set('country_id', null);
// $set('group_cc', null);
$set('group_id', null);
})
->placeholder('Country'),
}),
// Select::make('country_id')
// ->visible(fn () => in_array(Auth()->user()->provider_id, [3, 4]))
// ->placeholder('Country')
// ->hiddenLabel()
// ->label('')
// ->searchable()
// ->preload()
// ->multiple()
// ->columnSpan(2)
// ->live()
// ->options(function (Get $get) {
// return Mapper::query()->where('sport_id', $get('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()
// ->columnSpan(2)
// ->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();
// 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')
@@ -121,24 +144,28 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
->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())->whereIn('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())->whereIn('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();
}
// if ($get('country_id')) {
// return Mapper::query()->where('sport_id', $get('sport_id'))->where('provider_id', Auth::user()->provider_id)->where('starttime', '>', Carbon::now())->whereIn('country_id', $get('country_id'))->groupBy('group_id')->pluck('group', 'group_id')->toArray();
// } else
// if ($get('group_cc')) {
// return Mapper::query()->where('sport_id', $get('sport_id'))->where('provider_id', Auth::user()->provider_id)->where('starttime', '>', Carbon::now())->whereIn('group_cc', $get('group_cc'))->groupBy('group_id')->pluck('group', 'group_id')->toArray();
// } else {
// }
return Mapper::query()->where('sport_id', $get('sport_id'))->where('provider_id', Auth::user()->provider_id)->where('starttime', '>', Carbon::now())->groupBy('group_id')->pluck('group', 'group_id')->toArray();
})
->live(),
])
->query(function (Builder $query, array $data): Builder {
return $query
->when(
$data['country_id'],
fn (Builder $query, $country_id) => $query->whereIn('country_id', $country_id)
)->when(
$data['group_cc'],
fn (Builder $query, $group_cc) => $query->whereIn('group_cc', $group_cc)
$data['sport_id'],
fn (Builder $query, $sport_id) => $query->where('sport_id', $sport_id)
// )->when(
// $data['country_id'],
// fn (Builder $query, $country_id) => $query->whereIn('country_id', $country_id)
// )->when(
// $data['group_cc'],
// fn (Builder $query, $group_cc) => $query->whereIn('group_cc', $group_cc)
)->when(
$data['group_id'],
fn (Builder $query, $group_id) => $query->whereIn('group_id', $group_id)
+1 -1
View File
@@ -25,7 +25,7 @@ class MultilineClient extends Model
public function multiline_setting()
{
return $this->belongsTo(MultilineSetting::class)->where('sport_id', auth()->user()->sport_id);
return $this->belongsTo(MultilineSetting::class);
}
public function bookmaker()