comparing wip
This commit is contained in:
1 parent
0cf815c00f
commit
cfee6f6b99
23 files changed
+740
-370
No files matched your search
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\Events\Tables;
|
||||
|
||||
use App\Filament\Resources\Events\Tables\Tools\LoadBettypeSettings;
|
||||
use App\Filament\Resources\Events\Tables\Tools\LoadBettype;
|
||||
use App\Filament\Resources\Events\Tables\Tools\LoadMultiline;
|
||||
use App\Filament\Tables\Columns\ColumnOdds;
|
||||
use App\Filament\Tables\Columns\EventColumn;
|
||||
@@ -42,18 +42,20 @@ class EventsTable
|
||||
|
||||
public static $slots;
|
||||
|
||||
public static $bookmaker;
|
||||
|
||||
public static $filter;
|
||||
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
self::$user = User::getUser();
|
||||
|
||||
LoadBettypeSettings::load();
|
||||
|
||||
LoadMultiline::load();
|
||||
|
||||
LoadBettype::load();
|
||||
|
||||
return $table
|
||||
// ->poll('10s')
|
||||
->poll('10s')
|
||||
->striped()
|
||||
->deferLoading()
|
||||
->defaultPaginationPageOption(5)
|
||||
@@ -86,49 +88,63 @@ class EventsTable
|
||||
ColumnOdds::make('odds_2ways')->bettype('odds_2ways')
|
||||
->visible(fn () => in_array('odds_2ways', self::$bettype_settings))
|
||||
->verticalAlignment(VerticalAlignment::Start)
|
||||
->alignCenter()
|
||||
->width(200)
|
||||
->label('ML'),
|
||||
|
||||
TooltipOdds::make('mls1')->bettype('odds_2ways_s1')->label('')->visible(fn () => in_array('odds_2ways_s1', self::$bettype_settings)),
|
||||
ColumnOdds::make('odds_2ways_s1')->bettype('odds_2ways_s1')
|
||||
->visible(fn () => in_array('odds_2ways_s1', self::$bettype_settings))
|
||||
->verticalAlignment(VerticalAlignment::Start)
|
||||
->alignCenter()
|
||||
->width(200)
|
||||
->label('ML S1'),
|
||||
|
||||
TooltipOdds::make('1x2')->bettype('odds_3ways')->label('')->visible(fn () => in_array('odds_3ways', self::$bettype_settings)),
|
||||
ColumnOdds::make('odds_3ways')->bettype('odds_3ways')
|
||||
->visible(fn () => in_array('odds_3ways', self::$bettype_settings))
|
||||
->verticalAlignment(VerticalAlignment::Start)
|
||||
->alignCenter()
|
||||
->width(250)
|
||||
->label('1X2'),
|
||||
|
||||
TooltipOdds::make('total')->bettype('odds_totals')->label('')->visible(fn () => in_array('odds_totals', self::$bettype_settings)),
|
||||
ColumnOdds::make('odds_totals')->bettype('odds_totals')
|
||||
->visible(fn () => in_array('odds_totals', self::$bettype_settings))
|
||||
->verticalAlignment(VerticalAlignment::Start)
|
||||
->alignCenter()
|
||||
->width(250)
|
||||
->label('Totals'),
|
||||
|
||||
TooltipOdds::make('1x2ht')->bettype('odds_3ways_ht')->label('')->visible(fn () => in_array('odds_3ways_ht', self::$bettype_settings)),
|
||||
ColumnOdds::make('odds_3ways_ht')->bettype('odds_3ways_ht')
|
||||
->visible(fn () => in_array('odds_3ways_ht', self::$bettype_settings))
|
||||
->verticalAlignment(VerticalAlignment::Start)
|
||||
->alignCenter()
|
||||
->width(250)
|
||||
->label('1X2 HT'),
|
||||
|
||||
TooltipOdds::make('total_ht')->bettype('odds_totals_ht')->label('')->visible(fn () => in_array('odds_totals_ht', self::$bettype_settings)),
|
||||
ColumnOdds::make('odds_totals_ht')->bettype('odds_totals_ht')
|
||||
->visible(fn () => in_array('odds_totals_ht', self::$bettype_settings))
|
||||
->verticalAlignment(VerticalAlignment::Start)
|
||||
->alignCenter()
|
||||
->width(250)
|
||||
->label('Totals HT'),
|
||||
|
||||
TooltipOdds::make('ggng')->bettype('odds_ggng')->label('')->visible(fn () => in_array('odds_ggng', self::$bettype_settings)),
|
||||
ColumnOdds::make('odds_ggng')->bettype('odds_ggng')
|
||||
->visible(fn () => \in_array('odds_ggng', self::$bettype_settings))
|
||||
->verticalAlignment(VerticalAlignment::Start)
|
||||
->alignCenter()
|
||||
->width(200)
|
||||
->label('Goal No Goal'),
|
||||
|
||||
TooltipOdds::make('points')->bettype('odds_points')->label('')->visible(fn () => in_array('odds_points', self::$bettype_settings)),
|
||||
ColumnOdds::make('odds_points')->bettype('odds_points')
|
||||
->width(240)
|
||||
->visible(fn () => in_array('odds_points', self::$bettype_settings))
|
||||
->verticalAlignment(VerticalAlignment::Start)
|
||||
->width(250)
|
||||
->alignCenter()
|
||||
->label('Points'),
|
||||
|
||||
@@ -136,30 +152,40 @@ class EventsTable
|
||||
ColumnOdds::make('odds_totals_q1')->bettype('odds_totals_q1')
|
||||
->visible(fn () => in_array('odds_totals_q1', self::$bettype_settings))
|
||||
->verticalAlignment(VerticalAlignment::Start)
|
||||
->alignCenter()
|
||||
->width(250)
|
||||
->label('Totals Q1'),
|
||||
|
||||
TooltipOdds::make('points_q1')->bettype('odds_points_q1')->label('')->visible(fn () => in_array('odds_points_q1', self::$bettype_settings)),
|
||||
ColumnOdds::make('odds_points_q1')->bettype('odds_points_q1')
|
||||
->visible(fn () => in_array('odds_points_q1', self::$bettype_settings))
|
||||
->verticalAlignment(VerticalAlignment::Start)
|
||||
->alignCenter()
|
||||
->width(250)
|
||||
->label('Points Q1'),
|
||||
|
||||
TooltipOdds::make('dc')->bettype('odds_dc')->label('')->visible(fn () => in_array('odds_dc', self::$bettype_settings)),
|
||||
ColumnOdds::make('odds_dc')->bettype('odds_dc')
|
||||
->visible(fn () => \in_array('odds_dc', self::$bettype_settings))
|
||||
->verticalAlignment(VerticalAlignment::Start)
|
||||
->alignCenter()
|
||||
->width(250)
|
||||
->label('Double Chance'),
|
||||
|
||||
TooltipOdds::make('tq')->bettype('odds_tq')->label('')->visible(fn () => in_array('odds_tq', self::$bettype_settings)),
|
||||
ColumnOdds::make('odds_tq')->bettype('odds_tq')
|
||||
->visible(fn () => \in_array('odds_tq', self::$bettype_settings))
|
||||
->verticalAlignment(VerticalAlignment::Start)
|
||||
->alignCenter()
|
||||
->width(200)
|
||||
->label('To Qualify'),
|
||||
|
||||
TooltipOdds::make('dnb')->bettype('odds_dnb')->label('')->visible(fn () => in_array('odds_dnb', self::$bettype_settings)),
|
||||
ColumnOdds::make('odds_dnb')->bettype('odds_dnb')
|
||||
->visible(fn () => \in_array('odds_dnb', self::$bettype_settings))
|
||||
->verticalAlignment(VerticalAlignment::Start)
|
||||
->alignCenter()
|
||||
->width(200)
|
||||
->label('Draw No Bet'),
|
||||
|
||||
])->searchable(['id', 'home.name', 'away.name', 'betsapi_id', 'betradar_id', 'bet365_id', 'bwin_id', 'magnig_id', 'magken_id', 'lognig_id', 'logcol_id'])
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ namespace App\Filament\Resources\Events\Tables\Tools;
|
||||
use App\Filament\Resources\Events\Tables\EventsTable;
|
||||
use App\Models\BettypeUser;
|
||||
|
||||
class LoadBettypeSettings
|
||||
class LoadBettype
|
||||
{
|
||||
public static function load()
|
||||
{
|
||||
@@ -13,49 +13,39 @@ class LoadMultiline
|
||||
|
||||
public static function load()
|
||||
{
|
||||
// if (EventsTable::$user->sport_id == 1) {
|
||||
// $cb = ComparingBookmaker::where('sport_id', 1)->where('client_bookmaker_id', EventsTable::$user->bookmaker_id)->orderBy('sorting')->select('bookmaker_id', 'time_lastcheck', 'margin_threshold', 'is_active')->get()->toArray();
|
||||
// } else {
|
||||
// $cb = ComparingBookmaker::where('sport_id', '!=', 1)->where('client_bookmaker_id', EventsTable::$user->bookmaker_id)->orderBy('sorting')->select('bookmaker_id', 'time_lastcheck', 'margin_threshold', 'is_active')->get()->toArray();
|
||||
// }
|
||||
|
||||
$cb = ComparingBookmaker::where('sport_id', EventsTable::$user->sport_id)->where('client_bookmaker_id', EventsTable::$user->bookmaker_id)->orderBy('sorting')->select('bookmaker_id', 'time_lastcheck', 'margin_threshold', 'is_active')->get()->toArray();
|
||||
$cb = ComparingBookmaker::where('sport_id', EventsTable::$user->sport_id)
|
||||
->where('client_bookmaker_id', EventsTable::$user->bookmaker_id)
|
||||
->orderBy('sorting')
|
||||
->select('bookmaker_id', 'time_lastcheck', 'margin_threshold', 'is_active')
|
||||
->get();
|
||||
|
||||
$bookmakers = [];
|
||||
$filter = [];
|
||||
foreach ($cb as $value) {
|
||||
$bookmakers[] = $value['bookmaker_id'];
|
||||
$filter[$value['bookmaker_id']] = [
|
||||
'time_lastcheck' => $value['time_lastcheck'],
|
||||
'margin' => $value['margin_threshold'],
|
||||
];
|
||||
if (EventsTable::$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', EventsTable::$user->sport_id)->get();
|
||||
|
||||
foreach ($res as $value) {
|
||||
EventsTable::$filter[$value->table] = $filter;
|
||||
if (EventsTable::$user->is_multiline_direct) {
|
||||
EventsTable::$slots[$value->table] = $bookmakers;
|
||||
array_unshift(EventsTable::$slots[$value->table], EventsTable::$user->bookmaker_id);
|
||||
}
|
||||
|
||||
EventsTable::$bookmaker[$value->table] = $bookmakers;
|
||||
}
|
||||
|
||||
if (! EventsTable::$user->is_multiline_direct) {
|
||||
$res = MultilineClient::with('multiline_setting')
|
||||
->select('bookmaker_id', 'multiline_setting_id')
|
||||
->orderBy('sort')
|
||||
->get();
|
||||
$res = MultilineClient::with('multiline_setting')
|
||||
->select('bookmaker_id', 'multiline_setting_id')
|
||||
->orderBy('sort')
|
||||
->get();
|
||||
|
||||
foreach ($res as $value) {
|
||||
$table = $value->multiline_setting->table;
|
||||
|
||||
if (! isset(EventsTable::$slots[$table])) {
|
||||
EventsTable::$slots[$table][] = (int) EventsTable::$user->bookmaker_id;
|
||||
}
|
||||
EventsTable::$slots[$table][] = (int) $value->bookmaker_id;
|
||||
}
|
||||
foreach ($res as $value) {
|
||||
$table = $value->multiline_setting->table;
|
||||
EventsTable::$slots[$table][] = (int) $value->bookmaker_id;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,44 +11,55 @@ class ColumnOdds extends Column
|
||||
|
||||
public $data;
|
||||
|
||||
protected ?array $filter;
|
||||
|
||||
protected ?array $slots;
|
||||
protected $filter;
|
||||
|
||||
protected $bettype;
|
||||
|
||||
public $slots;
|
||||
|
||||
public $bookmaker;
|
||||
|
||||
protected $max;
|
||||
|
||||
protected $min;
|
||||
|
||||
protected $columns;
|
||||
|
||||
protected $client;
|
||||
|
||||
public $compare;
|
||||
|
||||
protected ?array $odds_labels;
|
||||
|
||||
protected ?int $has_data;
|
||||
protected bool $state = true;
|
||||
|
||||
public function loadData($record)
|
||||
{
|
||||
// $this->setMinMax($record);
|
||||
|
||||
$this->setSlots();
|
||||
|
||||
$this->getData($record);
|
||||
|
||||
if (! $this->data) {
|
||||
$this->has_data = 0;
|
||||
$this->state = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->setSlots();
|
||||
|
||||
$this->has_data = count($this->data);
|
||||
|
||||
$order = EventsTable::$slots ?? [];
|
||||
$order = $this->getSlots();
|
||||
$this->data->sortBy(function ($model) use ($order) {
|
||||
return array_search($model->bookmaker_id, $order);
|
||||
});
|
||||
|
||||
$this->setCompare($record);
|
||||
|
||||
return $this->data;
|
||||
}
|
||||
|
||||
/*******************************
|
||||
* PARENT
|
||||
*******************************/
|
||||
public function bettype(string $bettype): static
|
||||
{
|
||||
$this->bettype = $bettype;
|
||||
@@ -56,6 +67,10 @@ class ColumnOdds extends Column
|
||||
return $this;
|
||||
}
|
||||
|
||||
/*******************************
|
||||
* GETTER
|
||||
*******************************/
|
||||
|
||||
public function getBettype()
|
||||
{
|
||||
return $this->bettype;
|
||||
@@ -66,19 +81,18 @@ class ColumnOdds extends Column
|
||||
return $this->columns;
|
||||
}
|
||||
|
||||
public function setSlots(): void
|
||||
public function getSlots()
|
||||
{
|
||||
$this->slots = EventsTable::$slots[$this->bettype];
|
||||
if (auth()->user()->is_multiline_direct) {
|
||||
return $this->bookmaker;
|
||||
} else {
|
||||
return $this->slots;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSlots(): ?array
|
||||
public function getState(): bool
|
||||
{
|
||||
return $this->slots;
|
||||
}
|
||||
|
||||
public function hasData()
|
||||
{
|
||||
return $this->has_data;
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
public function getClient()
|
||||
@@ -86,6 +100,11 @@ class ColumnOdds extends Column
|
||||
return $this->client;
|
||||
}
|
||||
|
||||
public function getCompare()
|
||||
{
|
||||
return $this->compare;
|
||||
}
|
||||
|
||||
public function getMax()
|
||||
{
|
||||
return $this->max;
|
||||
@@ -98,6 +117,8 @@ class ColumnOdds extends Column
|
||||
|
||||
public function getData($record)
|
||||
{
|
||||
$this->client = null;
|
||||
$this->data = null;
|
||||
switch ($this->bettype) {
|
||||
case 'odds_2ways':
|
||||
$this->data = $record->odds_2ways;
|
||||
@@ -217,6 +238,10 @@ class ColumnOdds extends Column
|
||||
return $this->odds_labels;
|
||||
}
|
||||
|
||||
/*******************************
|
||||
* SETTER
|
||||
*******************************/
|
||||
|
||||
public function setMinMax($record)
|
||||
{
|
||||
switch ($this->bettype) {
|
||||
@@ -287,4 +312,33 @@ class ColumnOdds extends Column
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function setCompare($record)
|
||||
{
|
||||
$this->compare = null;
|
||||
$this->data->filter(function ($model) {
|
||||
|
||||
if ($model->bookmaker_id != auth()->user()->bookmaker_id) {
|
||||
|
||||
$filter = $this->filter[$model->bookmaker_id] ?? 0;
|
||||
|
||||
if ($filter) {
|
||||
if ($model->margin <= $filter['margin']) {
|
||||
$this->compare = $this->data->where('bookmaker_id', $model->bookmaker_id)->first();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function setSlots()
|
||||
{
|
||||
$this->slots = EventsTable::$slots[$this->bettype];
|
||||
|
||||
$this->bookmaker = EventsTable::$bookmaker[$this->bettype];
|
||||
|
||||
$this->filter = EventsTable::$filter[$this->bettype];
|
||||
}
|
||||
}
|
||||
@@ -140,6 +140,6 @@ class Event extends Model
|
||||
|
||||
public function event_user_star()
|
||||
{
|
||||
return $this->hasOne(EventUserStar::class, 'event_id', 'id');
|
||||
return $this->hasOne(EventUserStar::class, 'event_id', 'id')->where('user_id', auth()->user()->id);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -182,6 +182,6 @@ class User extends Authenticatable implements FilamentUser, HasAppAuthentication
|
||||
|
||||
public static function getUser()
|
||||
{
|
||||
return User::find(auth()->user()->id);
|
||||
return User::with('bookmaker')->find(auth()->user()->id);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user