53 lines
1.7 KiB
PHP
53 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Events\Tables\Tools;
|
|
|
|
use App\Filament\Resources\Events\Tables\EventsTable;
|
|
use App\Models\ComparingBookmaker;
|
|
use App\Models\MultilineClient;
|
|
use App\Models\MultilineSetting;
|
|
|
|
class LoadMultiline
|
|
{
|
|
public static $user;
|
|
|
|
public static function load()
|
|
{
|
|
$cb = ComparingBookmaker::where('sport_id', auth()->user()->sport_id)
|
|
->where('client_bookmaker_id', auth()->user()->bookmaker_id)
|
|
->orderBy('sorting', 'desc')
|
|
->select('bookmaker_id', 'time_lastcheck', 'margin_threshold', 'is_active')
|
|
->get();
|
|
|
|
$bookmakers = [];
|
|
$filter = [];
|
|
foreach ($cb as $value) {
|
|
if (auth()->user()->bookmaker_id != $value->bookmaker_id) {
|
|
$bookmakers[] = $value->bookmaker_id;
|
|
$filter[$value->bookmaker_id] = [
|
|
'time_lastcheck' => $value->time_lastcheck,
|
|
'margin' => $value->margin_threshold,
|
|
];
|
|
}
|
|
}
|
|
|
|
$res = MultilineSetting::where('sport_id', auth()->user()->sport_id)->get();
|
|
|
|
foreach ($res as $value) {
|
|
EventsTable::$filter[$value->table] = $filter;
|
|
EventsTable::$bookmaker[$value->table] = $bookmakers;
|
|
}
|
|
|
|
$res = MultilineClient::with('multiline_setting')
|
|
->where('client_bookmaker_id', auth()->user()->bookmaker_id)
|
|
->select('bookmaker_id', 'multiline_setting_id')
|
|
->orderBy('sort')
|
|
->get();
|
|
|
|
foreach ($res as $value) {
|
|
$table = $value->multiline_setting->table;
|
|
EventsTable::$slots[$table][] = (int) $value->bookmaker_id;
|
|
}
|
|
}
|
|
}
|