ComparingBookmakerMenu ok

This commit is contained in:
salam committed 2026-01-21 09:54:12 +01:00
1 parent be80128226
commit f59ac10c2a
17 files changed
+272 -317

No files matched your search

@@ -9,8 +9,6 @@ use App\Models\Client;
use App\Models\ComparingBookmaker;
use App\Models\MultilineClient;
use App\Models\MultilineSetting;
use App\Models\Odds2way;
use App\Models\Odds3way;
use App\Models\Sport;
use App\Models\User;
use App\Utilities\Notice;
@@ -79,56 +77,59 @@ class GenerateDefaultSetting
Notice::note('3) comparing bookmaker', 'p');
}
$bookmakers = Bookmaker::get();
$res = Client::get();
$bookmakers_soccer = Bookmaker::where('in_soccer', 1)->orderBy('name')->pluck('id')->toArray();
ComparingBookmaker::where('method_id', 1)->where('sport_id', 1)->whereNotIn('bookmaker_id', $bookmakers_soccer)->delete();
foreach ($res as $client) {
$client_bookmakers = $client->bookmaker;
$sports = $client->sport;
foreach ($sports as $sport_id) {
switch ($sport_id) {
case 1:
$in_table_bookmaker = Odds3way::where('sport_id', $sport_id)->groupBy('bookmaker_id')->pluck('bookmaker_id')->toArray();
break;
case 2:
case 3:
case 5:
$in_table_bookmaker = Odds2way::where('sport_id', $sport_id)->groupBy('bookmaker_id')->pluck('bookmaker_id')->toArray();
break;
}
foreach ($client_bookmakers as $client_bookmaker_id) {
$i = 0;
foreach ($bookmakers as $bookmaker) {
$i = 1;
foreach ($bookmakers_soccer as $bookmaker_id) {
ComparingBookmaker::updateOrCreate(
['method_id' => 1, 'sport_id' => 1, 'client_bookmaker_id' => $client_bookmaker_id, 'bookmaker_id' => $bookmaker_id],
['is_active' => 1, 'time_lastcheck' => 600, 'margin_threshold' => 110, 'sorting' => $i]
);
$i++;
$is_hidden = \in_array($bookmaker->id, $in_table_bookmaker) ? 0 : 1;
}
}
}
foreach ($client_bookmakers as $client_bookmaker_id) {
$sports = Sport::getActiveSports();
if (($key = array_search(1, $sports)) !== false) {
unset($sports[$key]);
}
if ($client_bookmaker_id != $bookmaker->id) {
$bookmakers_other = Bookmaker::where('in_other', 1)->orderBy('name')->pluck('id')->toArray();
if ($bookmaker->is_active) {
for ($method_id = 1; $method_id <= 4; $method_id++) {
ComparingBookmaker::updateOrCreate(
['method_id' => $method_id, 'sport_id' => $sport_id, 'client_bookmaker_id' => $client_bookmaker_id, 'bookmaker_id' => $bookmaker->id],
['is_hidden' => $is_hidden, 'is_active' => 1, 'time_lastcheck' => 600, 'margin_threshold' => 110, 'sorting' => $i]
);
}
} else {
for ($method_id = 1; $method_id <= 4; $method_id++) {
ComparingBookmaker::where('method_id', $method_id)
->where('sport_id', $sport_id)
->where('bookmaker_id', $bookmaker->id)
->where('client_bookmaker_id', $client_bookmaker_id)
->delete();
}
}
}
ComparingBookmaker::where('method_id', 1)->whereIn('sport_id', $sports)->whereNotIn('bookmaker_id', $bookmakers_other)->delete();
foreach ($res as $client) {
$client_bookmakers = $client->bookmaker;
foreach ($client_bookmakers as $client_bookmaker_id) {
foreach ($sports as $sport_id) {
$i = 1;
foreach ($bookmakers_other as $bookmaker_id) {
ComparingBookmaker::updateOrCreate(
['method_id' => 1, 'sport_id' => $sport_id, 'client_bookmaker_id' => $client_bookmaker_id, 'bookmaker_id' => $bookmaker_id],
['is_active' => 1, 'time_lastcheck' => 600, 'margin_threshold' => 110, 'sorting' => $i]
);
$i++;
}
}
}
}
}
}
@@ -6,6 +6,7 @@ use App\Filament\Tables\Columns\BookmakerIcon;
use Filament\Actions\EditAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Columns\ToggleColumn;
use Filament\Tables\Enums\FiltersLayout;
use Filament\Tables\Filters\TernaryFilter;
use Filament\Tables\Table;
@@ -15,30 +16,32 @@ class BookmakersTable
{
return $table
->striped()
->recordAction(null)
->defaultPaginationPageOption(5)
->columns([
TextColumn::make('id')->searchable(),
TextColumn::make('name')
->searchable(),
BookmakerIcon::make('icon')->label('Icon'),
TextColumn::make('baid')
->label('BAID')
->numeric()
->sortable(),
ToggleColumn::make('txso')->offColor('gray'),
ToggleColumn::make('txot')->offColor('gray'),
ToggleColumn::make('betsapi')->offColor('gray'),
ToggleColumn::make('direct')->offColor('gray'),
ToggleColumn::make('is_active')->offColor('gray'),
TextColumn::make('name')->searchable(),
BookmakerIcon::make('icon')->label('Icon')->size('lg'),
ToggleColumn::make('in_soccer')->onColor('success'),
ToggleColumn::make('in_other')->onColor('success'),
ToggleColumn::make('txso'),
ToggleColumn::make('txot'),
ToggleColumn::make('betsapi'),
ToggleColumn::make('direct'),
ToggleColumn::make('is_active')->onColor('success'),
ToggleColumn::make('need_check')->onColor('danger'),
])
->defaultSort('name')
->defaultSort('id')
->filters([
TernaryFilter::make('in_soccer'),
TernaryFilter::make('in_other'),
TernaryFilter::make('txso'),
TernaryFilter::make('txot'),
TernaryFilter::make('betsapi'),
TernaryFilter::make('direct'),
TernaryFilter::make('is_active')->default(true),
])
TernaryFilter::make('need_check'),
], FiltersLayout::AboveContent)
->deferFilters(false)
->recordActions([
EditAction::make()->hiddenLabel(),
]);
@@ -1,20 +0,0 @@
<?php
namespace App\Livewire\ComparingBookmaker;
use App\Models\ComparingBookmaker;
use App\Models\User;
class LoadBookmaker
{
public static function load()
{
$user = User::find(auth()->user()->id);
return ComparingBookmaker::query()
->with('bookmaker')
->where('sport_id', $user->sport_id)
->where('client_bookmaker_id', $user->bookmaker_id)
->orderBy('sorting');
}
}
+23 -53
View File
@@ -3,14 +3,13 @@
namespace App\Livewire;
use App\Filament\Tables\Columns\BookmakerIcon;
use App\Livewire\ComparingBookmaker\LoadBookmaker;
use App\Models\ComparingBookmaker;
use App\Models\User;
use Filament\Actions\Action;
use Filament\Actions\BulkAction;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\Concerns\InteractsWithActions;
use Filament\Actions\Contracts\HasActions;
use Filament\Forms\Components\Radio;
use Filament\Forms\Components\TextInput;
use Filament\Schemas\Concerns\InteractsWithSchemas;
use Filament\Schemas\Contracts\HasSchemas;
@@ -20,12 +19,9 @@ use Filament\Tables\Columns\ToggleColumn;
use Filament\Tables\Concerns\InteractsWithTable;
use Filament\Tables\Contracts\HasTable;
use Filament\Tables\Enums\FiltersLayout;
use Filament\Tables\Filters\Filter;
use Filament\Tables\Filters\Indicator;
use Filament\Tables\Filters\TernaryFilter;
use Filament\Tables\Table;
use Illuminate\Contracts\View\View;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Collection;
use Livewire\Component;
@@ -35,83 +31,57 @@ class ComparingBookmakerMenu extends Component implements HasActions, HasSchemas
use InteractsWithSchemas;
use InteractsWithTable;
public $user;
protected $listeners = [
'refresh' => '$refresh',
];
public function table(Table $table): Table
{
$this->user = User::getUser();
return $table
->description('')
->description('Bookmaker order is priority. Maximum time than can pass since last check or update. If older bookmaker will be ignored')
->description('Bookmakers will be compared from top to bottom. First one matches criteria is used for comparition.')
->reorderable('sorting')
->reorderRecordsTriggerAction(function (Action $action) {
return $action->button();
})
->paginated(false)
->striped()
->query(LoadBookmaker::load())
->query(ComparingBookmaker::query()
->with('bookmaker')
->where('sport_id', $this->user->sport_id)
->where('client_bookmaker_id', $this->user->bookmaker_id)
->orderBy('sorting')
)
->columns([
TextColumn::make('Position')
->alignCenter()
->badge()
->rowIndex(),
TextColumn::make('bookmaker_id')->label('Id'),
BookmakerIcon::make('bookmaker.icon')->label('Icon'),
BookmakerIcon::make('bookmaker.icon')->label('Icon')->size('lg'),
TextInputColumn::make('time_lastcheck')
->tooltip('If lastcheck is older bookmaker will be ignored')
->label('Time Passed')
->prefix('Seconds:')
->rules(['required', 'max:200', 'min:100']),
TextInputColumn::make('margin_threshold')
->tooltip('If margin is higher bookmaker will be ignored')
->label('Maximum Margin')
->prefix('Threshold:')
->rules(['required', 'max:200', 'min:100']),
ToggleColumn::make('is_active'),
// ToggleColumn::make('is_active'),
])
->filters([
Filter::make('method_id')
->schema([
Radio::make('method_id')
->inline()
->default(1)
->label('League / Tournament Level')
->options([
1 => 'TOP',
2 => 'MIDDLE',
3 => 'LOW',
]),
])
->query(function (Builder $query, array $data): Builder {
return $query
->when(
$data['method_id'],
fn (Builder $query, $method_id): Builder => $query->where('method_id', $method_id),
);
})->indicateUsing(function (array $data): array {
$indicators = [];
if ($data['method_id'] ?? null) {
switch ($data['method_id']) {
case 1:
$indicators[] = Indicator::make('Method: TOP');
break;
case 2:
$indicators[] = Indicator::make('Method: MIDDLE');
break;
case 3:
$indicators[] = Indicator::make('Method: LOW');
break;
}
}
return $indicators;
})->columnSpan(6),
TernaryFilter::make('is_active')
->columnSpan(2)
->default(1)
->label('Show active'),
], layout: FiltersLayout::AboveContent)
->filtersFormColumns(8)
->searchable(['bookmaker.name'])
// ->filters([
// TernaryFilter::make('is_active')
// ->columnSpan(2)
// ->default(1)
// ->label('Show active'),
// ], layout: FiltersLayout::AboveContent)
->deferFilters(false)
->toolbarActions([
BulkActionGroup::make([
+5 -3
View File
@@ -7,7 +7,7 @@ use Illuminate\Support\Carbon;
class LoadProvider
{
public static function load($search_right)
public static function load($search_right, $user)
{
if ($search_right) {
@@ -15,7 +15,8 @@ class LoadProvider
return Mapper::query()
->where('starttime', '>', Carbon::now())
->where('provider_id', auth()->user()->provider_id)
->where('sport_id', $user->sport_id)
->where('provider_id', $user->provider_id)
->where(function ($query) use ($searchValues) {
foreach ($searchValues as $value) {
$query->orWhere('home', 'LIKE', '%'.$value.'%')
@@ -25,7 +26,8 @@ class LoadProvider
} else {
return Mapper::query()
->where('starttime', '>', Carbon::now())
->where('provider_id', auth()->user()->provider_id);
->where('sport_id', $user->sport_id)
->where('provider_id', $user->provider_id);
}
}
}
+7 -12
View File
@@ -9,7 +9,7 @@ use App\Models\CompetitionGroup;
use App\Models\Country;
use App\Models\Event;
use App\Models\Mapper;
use App\Models\Sport;
use App\Models\User;
use Carbon\Carbon;
use Filament\Actions\Action;
use Filament\Actions\Concerns\InteractsWithActions;
@@ -42,7 +42,7 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
public $search_left = false;
public $sport_id = 0;
public $user;
protected $listeners = [
'reload_data_left' => '$refresh',
@@ -67,10 +67,10 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
public function table(Table $table): Table
{
$this->setSportId();
$this->user = User::getUser();
return $table
->query(LoadEvents::load($this->search_left, $this->sport_id))
->query(LoadEvents::load($this->search_left, $this->user->sport_id))
->columns([
MapperLeftColumn::make('left')->label(''),
])
@@ -87,7 +87,7 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
->searchable()
->preload()
->options(function () {
$res = Event::query()->where('sport_id', $this->sport_id)->where('betradar_id', 0)->where('starttime', '>', Carbon::now())->groupBy('country_id')->pluck('country_id')->toArray();
$res = Event::query()->where('sport_id', $this->user->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');
})
@@ -105,9 +105,9 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
->searchable()
->options(function (Get $get) {
if ($get('country_id')) {
$res = Event::query()->where('sport_id', $this->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();
$res = Event::query()->where('sport_id', $this->user->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', $this->sport_id)->where('betradar_id', 0)->where('starttime', '>', Carbon::now())->groupBy('competition_group_id')->pluck('competition_group_id')->toArray();
$res = Event::query()->where('sport_id', $this->user->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();
@@ -172,11 +172,6 @@ class MapperLeft extends Component implements HasActions, HasSchemas, HasTable
$this->elements_swopped = ! $this->elements_swopped;
}
public function setSportId()
{
$this->sport_id = Sport::getSportId();
}
#[On('search_left')]
public function searchLeft($str)
{
+51 -88
View File
@@ -8,7 +8,7 @@ use App\Livewire\Mapper\StoreMapped;
use App\Models\Country;
use App\Models\Event;
use App\Models\Mapper;
use App\Models\Sport;
use App\Models\User;
use Filament\Actions\Action;
use Filament\Actions\Concerns\InteractsWithActions;
use Filament\Actions\Contracts\HasActions;
@@ -26,7 +26,6 @@ use Filament\Tables\Filters\Indicator;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Auth;
use Livewire\Attributes\Lazy;
use Livewire\Attributes\On;
use Livewire\Component;
@@ -46,6 +45,8 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
'reload_data_right' => '$refresh',
];
public $user;
public function removeTableFilter(string $filterName, ?string $field = null, bool $shouldTriggerUpdatedFiltersHook = true): void
{
$searchValues = preg_split('/\s+/', $this->search_right, -1, PREG_SPLIT_NO_EMPTY);
@@ -65,8 +66,10 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
public function table(Table $table): Table
{
$this->user = User::getUser();
return $table
->query(LoadProvider::load($this->search_right))
->query(LoadProvider::load($this->search_right, $this->user))
->columns([
MapperRightColumn::make('right')->label(''),
])->searchable(['home', 'away'])
@@ -74,66 +77,44 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
->filters([
Filter::make('events')
->schema([
Select::make(name: 'sport_id')
->default(auth()->user()->sport_id)
->prefixIcon(auth()->user()->sport->icon)
->selectablePlaceholder(false)
Select::make('country_id')
->visible(fn () => in_array($this->user->provider_id, [3, 4]))
->placeholder('Country')
->hiddenLabel()
->columnSpan(2)
->label('')
->searchable()
->preload()
->options(function () {
return Sport::query()->where('is_active', 1)->pluck('name', 'id');
})
->multiple()
->columnSpan(2)
->live()
->options(function (Get $get) {
return Mapper::query()->where('sport_id', $this->user->sport_id)->where('provider_id', $this->user->provider_id)->where('starttime', '>', Carbon::now())->groupBy('country_id')->pluck('country', 'country_id')->toArray();
})
->reactive()
->afterStateUpdated(function (callable $set, $livewire) {
$livewire->dispatch('reload_data_left');
$livewire->dispatch('reload_data_right');
// $set('country_id', null);
// $set('group_cc', null);
->afterStateUpdated(function (callable $set) {
$set('group_id', null);
})
->placeholder('Country'),
Select::make('group_cc')
->visible(fn () => $this->user->provider_id == 2)
->placeholder('Country')
->hiddenLabel()
->label('')
->searchable()
->preload()
->multiple()
->columnSpan(2)
->live()
->options(function () {
$res = Mapper::query()->where('sport_id', $this->user->sport_id)->where('provider_id', $this->user->provider_id)->where('starttime', '>', Carbon::now())->groupBy('group_cc')->pluck('group_cc')->toArray();
}),
// 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'),
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')
@@ -144,28 +125,24 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
->preload()
->multiple()
->options(function (Get $get) {
// 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();
if ($get('country_id')) {
return Mapper::query()->where('sport_id', $this->user->sport_id)->where('provider_id', $this->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', $this->user->sport_id)->where('provider_id', $this->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', $this->user->sport_id)->where('provider_id', $this->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['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)
$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)
@@ -199,6 +176,7 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
$livewire->fill(['tableSearch' => '']);
$livewire->resetTableFiltersForm(); // Clears all filters
$this->dispatch('reload_data_right');
$this->dispatch('reload_data_left');
}),
]);
}
@@ -216,21 +194,6 @@ class MapperRight extends Component implements HasActions, HasSchemas, HasTable
$this->dispatch('reload_data_right');
}
// In the same Table class
protected function removeTableFilters(): void
{
// Custom logic before or after removing filters
// Example: Log the action
\Log::info('Custom filter removal logic triggered.');
// Call the parent method to perform the default removal
parent::removeTableFilters();
// Or, if you want full control, you can manually clear:
// $this->tableFilters = [];
// $this->dispatch('refresh-table');
}
public function rightAction(): Action
{
return Action::make('right')
+12 -6
View File
@@ -6,6 +6,7 @@ use App\Filament\Tables\Columns\BookmakerIcon;
use App\Models\Bookmaker;
use App\Models\MultilineClient;
use App\Models\MultilineSetting;
use App\Models\User;
use Filament\Actions\Concerns\InteractsWithActions;
use Filament\Actions\Contracts\HasActions;
use Filament\Forms\Components\Radio;
@@ -32,17 +33,22 @@ class MultilineBookmaker extends Component implements HasActions, HasSchemas, Ha
public static $default_filter;
public static function load_filter()
public $user;
public static function load_filter($sport_id)
{
self::$default_filter = MultilineSetting::where('sport_id', auth()->user()->sport_id)->orderBy('id')->pluck('id')->first();
self::$default_filter = MultilineSetting::where('sport_id', $sport_id)->orderBy('id')->pluck('id')->first();
}
public function table(Table $table): Table
{
self::load_filter();
$this->user = User::getUser();
self::load_filter($this->user->sport_id);
return $table
->query(MultilineClient::query()->where('sport_id', auth()->user()->sport_id))
->query(MultilineClient::query()->where('sport_id', $this->user->sport_id))
->paginated(false)
->columns([
IconColumn::make('sport.icon')
@@ -61,7 +67,7 @@ class MultilineBookmaker extends Component implements HasActions, HasSchemas, Ha
$table = MultilineSetting::where('id', $livewire->tableFilters['multiline_setting_id'])->value('table');
$bookies = DB::table($table)
->where('sport_id', auth()->user()->sport_id)
->where('sport_id', $this->user->sport_id)
->groupBy('bookmaker_id')->pluck('bookmaker_id');
$res = Bookmaker::whereIn('id', $bookies)->pluck('name', 'id');
@@ -85,7 +91,7 @@ class MultilineBookmaker extends Component implements HasActions, HasSchemas, Ha
->columnSpan(6)
->columnSpanFull()
->hiddenLabel()
->options(fn () => MultilineSetting::where('sport_id', auth()->user()->sport_id)->orderBy('name')->pluck('name', 'id')),
->options(fn () => MultilineSetting::where('sport_id', $this->user->sport_id)->orderBy('name')->pluck('name', 'id')),
])
->query(function (Builder $query, array $data): Builder {
return $query
-1
View File
@@ -14,7 +14,6 @@ class ComparingBookmaker extends Model
'time_lastcheck',
'margin_threshold',
'is_active',
'is_hidden',
'sorting',
];
+5 -8
View File
@@ -28,6 +28,11 @@ class Sport extends Model
}
}
public static function getActiveSports()
{
return Sport::query()->where('is_active', 1)->pluck('id')->toArray();
}
public static function getSportForClient()
{
$user = User::find(auth()->user()->id);
@@ -37,12 +42,4 @@ class Sport extends Model
return Sport::query()->whereIn('id', $sports)->pluck('name', 'id');
}
public static function getSportId()
{
$user = User::find(auth()->user()->id);
return $user->sport_id;
}
}
+5
View File
@@ -176,4 +176,9 @@ class User extends Authenticatable implements FilamentUser, HasAppAuthentication
{
return Bookmaker::where('id', auth()->user()->bookmaker_id)->select('id', 'name', 'icon', 'svg')->first();
}
public static function getUser()
{
return User::find(auth()->user()->id);
}
}