popup fixed al ok
This commit is contained in:
1 parent
b0482cacf6
commit
82e6a60253
45 files changed
+8043
-1277
No files matched your search
@@ -22,33 +22,33 @@ class FilterOdds
|
||||
/**
|
||||
* FILTER
|
||||
*/
|
||||
if (! auth()->user()->no_filter) {
|
||||
// if (! auth()->user()->no_filter) {
|
||||
|
||||
$filter = $bookmakers['filter'] ?? [];
|
||||
// $filter = $bookmakers['filter'] ?? [];
|
||||
|
||||
if ($filter) {
|
||||
$data = $data->filter(function ($model) use ($filter) {
|
||||
// if ($filter) {
|
||||
// $data = $data->filter(function ($model) use ($filter) {
|
||||
|
||||
if ($model->bookmaker_id == auth()->user()->bookmaker_id) {
|
||||
return true;
|
||||
}
|
||||
// if ($model->bookmaker_id == auth()->user()->bookmaker_id) {
|
||||
// return true;
|
||||
// }
|
||||
|
||||
$filter = $filter[$model->bookmaker_id] ?? 0;
|
||||
// $filter = $filter[$model->bookmaker_id] ?? 0;
|
||||
|
||||
$checked_at = Carbon::createFromDate($model->checked_at)->timestamp;
|
||||
// $checked_at = Carbon::createFromDate($model->checked_at)->timestamp;
|
||||
|
||||
if (! isset($filter['margin'])) {
|
||||
Bookmakers::updateOrCreate(['id' => (int) $model->bookmaker_id], ['need_check' => 1]);
|
||||
}
|
||||
// if (! isset($filter['margin'])) {
|
||||
// Bookmakers::updateOrCreate(['id' => (int) $model->bookmaker_id], ['need_check' => 1]);
|
||||
// }
|
||||
|
||||
if ($model->margin <= $filter['margin'] && $checked_at > time() - $filter['time_lastcheck']) {
|
||||
return true;
|
||||
}
|
||||
// if ($model->margin <= $filter['margin'] && $checked_at > time() - $filter['time_lastcheck']) {
|
||||
// return true;
|
||||
// }
|
||||
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
// return false;
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
return $data;
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Tables\Columns;
|
||||
|
||||
use Filament\Tables\Columns\Column;
|
||||
|
||||
class PopupOdds extends Column
|
||||
{
|
||||
protected string $view = 'filament.tables.columns.popup-odds';
|
||||
|
||||
protected $max;
|
||||
|
||||
protected $min;
|
||||
|
||||
protected $act;
|
||||
|
||||
protected ?int $has_data;
|
||||
|
||||
public function loadData($record)
|
||||
{
|
||||
$this->has_data = count($record->odds_3ways);
|
||||
|
||||
$this->act = $record->odds_3ways->where('bookmaker_id', auth()->user()->bookmaker_id)->first();
|
||||
|
||||
$this->max['h3w'] = $record->odds_3ways->max('h3w');
|
||||
|
||||
$this->max['d3w'] = $record->odds_3ways->max('d3w');
|
||||
|
||||
$this->max['a3w'] = $record->odds_3ways->max('a3w');
|
||||
|
||||
$this->min['h3w'] = $record->odds_3ways->min('h3w');
|
||||
|
||||
$this->min['d3w'] = $record->odds_3ways->min('d3w');
|
||||
|
||||
$this->min['a3w'] = $record->odds_3ways->min('a3w');
|
||||
|
||||
}
|
||||
|
||||
public function getAct()
|
||||
{
|
||||
return $this->act;
|
||||
}
|
||||
|
||||
public function getMax()
|
||||
{
|
||||
return $this->max;
|
||||
}
|
||||
|
||||
public function getMin()
|
||||
{
|
||||
return $this->min;
|
||||
}
|
||||
|
||||
public function hasData()
|
||||
{
|
||||
return $this->has_data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,277 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Tables\Columns;
|
||||
|
||||
use App\Utilities\BkmIconMap;
|
||||
use Filament\Tables\Columns\Column;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class TooltipOdds extends Column
|
||||
{
|
||||
protected string $view = 'filament.tables.columns.tooltip-odds';
|
||||
|
||||
protected $bettype;
|
||||
|
||||
protected $two_cols_break = 9;
|
||||
|
||||
protected $pop;
|
||||
|
||||
protected $oddnames = [];
|
||||
|
||||
protected $data;
|
||||
|
||||
protected $max;
|
||||
|
||||
protected $min;
|
||||
|
||||
protected $size;
|
||||
|
||||
public function bettype($bettype): static
|
||||
{
|
||||
$this->bettype = $bettype;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPop()
|
||||
{
|
||||
return $this->pop;
|
||||
}
|
||||
|
||||
public function getSize()
|
||||
{
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
public function loadData($record)
|
||||
{
|
||||
switch ($this->bettype) {
|
||||
case 'odds_3ways':
|
||||
$this->oddnames = ['h3w', 'd3w', 'a3w'];
|
||||
|
||||
$this->data = $record->odds_3ways;
|
||||
break;
|
||||
case 'odds_3ways_ht':
|
||||
$this->oddnames = ['h3w', 'd3w', 'a3w'];
|
||||
|
||||
$this->data = $record->odds_3ways_ht;
|
||||
break;
|
||||
case 'odds_2ways':
|
||||
$this->oddnames = ['h2w', 'a2w'];
|
||||
|
||||
$this->data = $record->odds_2ways;
|
||||
break;
|
||||
case 'odds_2ways_s1':
|
||||
$this->oddnames = ['h2w', 'a2w'];
|
||||
|
||||
$this->data = $record->odds_2ways_s1;
|
||||
break;
|
||||
case 'odds_dc':
|
||||
$this->oddnames = ['dc1x', 'dc12', 'dcx2'];
|
||||
|
||||
$this->data = $record->odds_dc;
|
||||
break;
|
||||
case 'odds_ggng':
|
||||
$this->oddnames = ['gg', 'ng'];
|
||||
|
||||
$this->data = $record->odds_ggng;
|
||||
break;
|
||||
case 'odds_dnb':
|
||||
$this->oddnames = ['dnb1', 'dnb2'];
|
||||
|
||||
$this->data = $record->odds_dnb;
|
||||
break;
|
||||
case 'odds_tq':
|
||||
$this->oddnames = ['htq', 'atq'];
|
||||
|
||||
$this->data = $record->odds_tq;
|
||||
break;
|
||||
case 'odds_totals':
|
||||
$this->oddnames = ['over', 'under', 'total'];
|
||||
|
||||
$this->data = $record->odds_totals;
|
||||
break;
|
||||
case 'odds_totals_ht':
|
||||
$this->oddnames = ['over', 'under', 'total'];
|
||||
|
||||
$this->data = $record->odds_totals_ht;
|
||||
break;
|
||||
case 'odds_totals_q1':
|
||||
$this->oddnames = ['over', 'under', 'total'];
|
||||
|
||||
$this->data = $record->odds_totals_q1;
|
||||
break;
|
||||
|
||||
case 'odds_points':
|
||||
$this->oddnames = ['home', 'away', 'handicap'];
|
||||
|
||||
$this->data = $record->odds_points;
|
||||
break;
|
||||
case 'odds_points_q1':
|
||||
$this->oddnames = ['home', 'away', 'handicap'];
|
||||
|
||||
$this->data = $record->odds_points_q1;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (! $this->data) {
|
||||
return;
|
||||
}
|
||||
$this->size = \count($this->data);
|
||||
|
||||
$this->setMinMax();
|
||||
|
||||
$this->makeHeader();
|
||||
|
||||
$this->makeTooltip();
|
||||
|
||||
}
|
||||
|
||||
public function setMinMax()
|
||||
{
|
||||
foreach ($this->oddnames as $oddname) {
|
||||
if ($this->bettype == 'odds_dc') {
|
||||
$this->max[$oddname] = $this->data->where('margin', '<', 250)->max($oddname);
|
||||
$this->min[$oddname] = $this->data->where($oddname, '>', 1)->where('margin', '<', 250)->min($oddname);
|
||||
} else {
|
||||
$this->max[$oddname] = $this->data->where('margin', '<', 150)->max($oddname);
|
||||
$this->min[$oddname] = $this->data->where($oddname, '>', 1)->where('margin', '<', 150)->min($oddname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function makeTooltip()
|
||||
{
|
||||
foreach ($this->data as $k => $value) {
|
||||
$this->pop .= $this->getIcon($value);
|
||||
foreach ($this->oddnames as $oddname) {
|
||||
$this->pop .= $this->getOdd($value[$oddname], $oddname);
|
||||
}
|
||||
$this->pop .= $this->getMargin($value->margin);
|
||||
$this->pop .= $this->getCheck($value->checked_at);
|
||||
if ($k % 2 == 0 && $this->size > $this->two_cols_break) {
|
||||
$this->pop .= '<div></div>';
|
||||
}
|
||||
}
|
||||
$this->pop .= '</div>';
|
||||
}
|
||||
|
||||
public function getIcon($value)
|
||||
{
|
||||
$this->pop .= '<div class="h-3 m-0 bg-contain bg-center bg-no-repeat my-auto dark:opacity-80" title="'.$value->bookmaker_id.'" style="background-image: url('.BkmIconMap::get($value->bookmaker->icon).')"></div>';
|
||||
}
|
||||
|
||||
public function getOdd($odd, $name)
|
||||
{
|
||||
if ($odd == $this->max[$name]) {
|
||||
$str = '<div class="mb-0.5 ml-0.5 bg-green-600/25 rounded shadow">';
|
||||
} elseif ($odd == $this->min[$name]) {
|
||||
$str = '<div class="mb-0.5 ml-0.5 bg-blue-600/25 rounded shadow">';
|
||||
} else {
|
||||
$str = '<div class="mb-0.5 ml-0.5">';
|
||||
}
|
||||
$this->pop .= $str.number_format($odd, 2).'</div>';
|
||||
}
|
||||
|
||||
public function getMargin($odd)
|
||||
{
|
||||
$str = '<div class="mb-0.5 ml-0.5">';
|
||||
$this->pop .= $str.number_format($odd, 1).'</div>';
|
||||
}
|
||||
|
||||
public function getCheck($lastcheck)
|
||||
{
|
||||
$lastcheck_5min = Carbon::createFromDate($lastcheck)->addMinutes(5);
|
||||
$lastcheck_30min = Carbon::createFromDate($lastcheck)->addMinutes(30);
|
||||
$now = Carbon::now();
|
||||
|
||||
if ($lastcheck_30min->lt($now)) {
|
||||
$this->pop .= '<div class="text-xs text-nowrap bg-red-600/20 rounded shadow">';
|
||||
} elseif ($lastcheck_5min->lt($now)) {
|
||||
$this->pop .= '<div class="text-xs text-nowrap bg-blue-600/20 rounded">';
|
||||
} else {
|
||||
$this->pop .= '<div class="text-xs text-nowrap">';
|
||||
}
|
||||
|
||||
$this->pop .= Carbon::createFromDate($lastcheck)->format('H:i').'</div>';
|
||||
}
|
||||
|
||||
public function makeHeader()
|
||||
{
|
||||
|
||||
switch ($this->bettype) {
|
||||
case 'odds_3ways':
|
||||
case 'odds_3ways_ht':
|
||||
$title = '1X2';
|
||||
$labels = ['Book', '1', 'X', '2', 'Margin', 'Check'];
|
||||
$columns = 6;
|
||||
break;
|
||||
case 'odds_dc':
|
||||
$title = 'Double Chance';
|
||||
$labels = ['Book', '1X', '12', 'X2', 'Margin', 'Check'];
|
||||
$columns = 6;
|
||||
break;
|
||||
case 'odds_ggng':
|
||||
$title = 'Goal No Goal';
|
||||
$labels = ['Book', 'GG', 'NG', 'Margin', 'Check'];
|
||||
$columns = 5;
|
||||
break;
|
||||
case 'odds_dnb':
|
||||
$title = 'Draw No Bet';
|
||||
$labels = ['Book', 'Home', 'Away', 'Margin', 'Check'];
|
||||
$columns = 5;
|
||||
break;
|
||||
case 'odds_tq':
|
||||
$title = 'To Qualify';
|
||||
$labels = ['Book', 'Home', 'Away', 'Margin', 'Check'];
|
||||
$columns = 5;
|
||||
break;
|
||||
case 'odds_totals':
|
||||
case 'odds_totals_ht':
|
||||
case 'odds_totals_q1':
|
||||
$title = 'Totals';
|
||||
$labels = ['Book', 'Over', 'Under', 'Total', 'Margin', 'Check'];
|
||||
$columns = 6;
|
||||
break;
|
||||
case 'odds_2ways':
|
||||
case 'odds_2ways_s1':
|
||||
$title = 'Money Line';
|
||||
$labels = ['Book', 'Home', 'Away', 'Margin', 'Check'];
|
||||
$columns = 5;
|
||||
break;
|
||||
case 'odds_points':
|
||||
case 'odds_points_q1':
|
||||
$title = 'Points';
|
||||
$labels = ['Book', 'Home', 'Away', 'Handicap', 'Margin', 'Check'];
|
||||
$columns = 6;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if ($this->size > $this->two_cols_break) {
|
||||
if ($columns == 6) {
|
||||
$this->pop = '<div class="grid grid-cols-13 gap-2 m-5 z-100 text-xs text-center">';
|
||||
} else {
|
||||
$this->pop = '<div class="grid grid-cols-11 gap-2 m-5 z-100 text-xs text-center">';
|
||||
}
|
||||
} else {
|
||||
if ($columns == 6) {
|
||||
$this->pop = '<div class="grid grid-cols-6 gap-2 m-5 z-100 text-xs text-center">';
|
||||
} else {
|
||||
$this->pop = '<div class="grid grid-cols-5 gap-2 m-5 z-100 text-xs text-center">';
|
||||
}
|
||||
}
|
||||
$this->pop .= '<div class="col-span-full text-center text-md font-bold mb-2">'.$title.'</div>';
|
||||
|
||||
foreach ($labels as $label) {
|
||||
$this->pop .= '<div>'.$label.'</div>';
|
||||
}
|
||||
if ($this->size > $this->two_cols_break) {
|
||||
$this->pop .= '<div></div>';
|
||||
foreach ($labels as $label) {
|
||||
$this->pop .= '<div>'.$label.'</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user