diff --git a/app/Filament/Tables/Columns/TooltipOdds.php b/app/Filament/Tables/Columns/TooltipOdds.php index 882c4f67..801c308e 100644 --- a/app/Filament/Tables/Columns/TooltipOdds.php +++ b/app/Filament/Tables/Columns/TooltipOdds.php @@ -45,6 +45,8 @@ class TooltipOdds extends Column public function loadData($record) { + $this->pop = null; + switch ($this->bettype) { case 'odds_3ways': $this->oddnames = ['h3w', 'd3w', 'a3w']; @@ -122,8 +124,6 @@ class TooltipOdds extends Column $this->setMinMax(); - $this->makeHeader(); - $this->makeTooltip(); } @@ -143,60 +143,77 @@ class TooltipOdds extends Column public function makeTooltip() { + $html = $this->legend(); + + $html .= $this->makeHeader(); + foreach ($this->data as $k => $value) { - $this->getIcon($value); + $html .= $this->getIcon($value); foreach ($this->oddnames as $oddname) { - $this->getOdd($value[$oddname], $oddname); + $html .= $this->getOdd($value[$oddname], $oddname); } - $this->getMargin($value->margin); - $this->getUpdatedAt($value->updated_at); + $html .= $this->getMargin($value->margin); - $this->getFlags($value->flags); + $html .= $this->getUpdatedAt($value->updated_at); + + $html .= $this->getFlags($value->flags); if ($k % 2 == 0 && $this->size > $this->two_cols_break) { - $this->pop .= '
'; + $html .= '
'; } } - $this->pop .= ''; + + $this->pop .= $html.''; } public function getIcon($value) { - $this->pop .= '
'; + return '
'; } public function getOdd($odd, $name) { - if ($odd == $this->max[$name]) { + if ($odd == $this->max[$name] && ! in_array($name, ['total', 'handicap'])) { $str = '
'; - } elseif ($odd == $this->min[$name]) { + } elseif ($odd == $this->min[$name] && ! in_array($name, ['total', 'handicap'])) { $str = '
'; } else { $str = '
'; } - $this->pop .= $str.number_format($odd, 2).'
'; + + return $str.number_format($odd, 2).'
'; } public function getMargin($odd) { - $this->pop .= '
'.number_format($odd, 1).'
'; + return '
'.number_format($odd, 1).'
'; } public function getFlags($flags) { if ($flags) { - $this->pop .= '
✓
'; + return '
✓
'; } else { - $this->pop .= '
⚠
'; + return '
⚠
'; } } public function getUpdatedAt($updated_at) { - $this->pop .= '
'.Carbon::createFromDate($updated_at)->format('H:i').'
'; + return '
'.Carbon::createFromDate($updated_at)->format('H:i').'
'; + } + + public function legend() + { + $part = '
'; + $part .= '
Highest
'; + $part .= '
Lowest
'; + $part .= '
'; + + return $part; } public function makeHeader() @@ -206,46 +223,46 @@ class TooltipOdds extends Column case 'odds_3ways': case 'odds_3ways_ht': $title = '1X2'; - $labels = ['Book', '1', 'X', '2', 'Margin', 'Check']; + $labels = ['Book', '1', 'X', '2', 'Margin', 'Changed', 'Status']; $columns = 6; break; case 'odds_dc': $title = 'Double Chance'; - $labels = ['Book', '1X', '12', 'X2', 'Margin', 'Check']; + $labels = ['Book', '1X', '12', 'X2', 'Margin', 'Changed', 'Status']; $columns = 6; break; case 'odds_ggng': $title = 'Goal No Goal'; - $labels = ['Book', 'GG', 'NG', 'Margin', 'Check']; + $labels = ['Book', 'GG', 'NG', 'Margin', 'Changed', 'Status']; $columns = 5; break; case 'odds_dnb': $title = 'Draw No Bet'; - $labels = ['Book', 'Home', 'Away', 'Margin', 'Check']; + $labels = ['Book', 'Home', 'Away', 'Margin', 'Changed', 'Status']; $columns = 5; break; case 'odds_tq': $title = 'To Qualify'; - $labels = ['Book', 'Home', 'Away', 'Margin', 'Check']; + $labels = ['Book', 'Home', 'Away', 'Margin', 'Changed', 'Status']; $columns = 5; break; case 'odds_totals': case 'odds_totals_ht': case 'odds_totals_q1': $title = 'Totals'; - $labels = ['Book', 'Over', 'Under', 'Total', 'Margin', 'Check']; + $labels = ['Book', 'Over', 'Under', 'Total', 'Margin', 'Changed', 'Status']; $columns = 6; break; case 'odds_2ways': case 'odds_2ways_s1': $title = 'Money Line'; - $labels = ['Book', 'Home', 'Away', 'Margin', 'Check']; + $labels = ['Book', 'Home', 'Away', 'Margin', 'Changed', 'Status']; $columns = 5; break; case 'odds_points': case 'odds_points_q1': $title = 'Points'; - $labels = ['Book', 'Home', 'Away', 'Handicap', 'Margin', 'Check']; + $labels = ['Book', 'Home', 'Away', 'Handicap', 'Margin', 'Changed', 'Status']; $columns = 6; break; @@ -253,27 +270,29 @@ class TooltipOdds extends Column if ($this->size > $this->two_cols_break) { if ($columns == 6) { - $this->pop = '
'; + $part = '
'; } else { - $this->pop = '
'; + $part = '
'; } } else { if ($columns == 6) { - $this->pop = '
'; + $part = '
'; } else { - $this->pop = '
'; + $part = '
'; } } - $this->pop .= '
'.$title.'
'; + $part .= '
'.$title.'
'; foreach ($labels as $label) { - $this->pop .= '
'.$label.'
'; + $part .= '
'.$label.'
'; } if ($this->size > $this->two_cols_break) { - $this->pop .= '
'; + $part .= '
'; foreach ($labels as $label) { - $this->pop .= '
'.$label.'
'; + $part .= '
'.$label.'
'; } } + + return $part; } } diff --git a/composer.lock b/composer.lock index 0d0dcf1a..3e630d95 100644 --- a/composer.lock +++ b/composer.lock @@ -12814,12 +12814,12 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": [], "prefer-stable": true, "prefer-lowest": false, "platform": { "php": "^8.3" }, - "platform-dev": {}, - "plugin-api-version": "2.9.0" + "platform-dev": [], + "plugin-api-version": "2.6.0" }