tooltip with legend and updatete_at

This commit is contained in:
salam committed 2026-01-27 10:22:15 +01:00
1 parent ec6d4863a9
commit e5c17d4627
2 files changed
+55 -36

No files matched your search

+52 -33
View File
@@ -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 .= '<div></div>';
$html .= '<div></div>';
}
}
$this->pop .= '</div>';
$this->pop .= $html.'</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>';
return '<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]) {
if ($odd == $this->max[$name] && ! in_array($name, ['total', 'handicap'])) {
$str = '<div class="mb-0.5 ml-0.5 bg-green-600/25 rounded shadow">';
} elseif ($odd == $this->min[$name]) {
} elseif ($odd == $this->min[$name] && ! in_array($name, ['total', 'handicap'])) {
$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>';
return $str.number_format($odd, 2).'</div>';
}
public function getMargin($odd)
{
$this->pop .= '<div class="mb-0.5 ml-0.5">'.number_format($odd, 1).'</div>';
return '<div class="mb-0.5 ml-0.5">'.number_format($odd, 1).'</div>';
}
public function getFlags($flags)
{
if ($flags) {
$this->pop .= '<div class="pb-0.5 text-green-600">&check;</div>';
return '<div class="pb-0.5 text-green-600">&check;</div>';
} else {
$this->pop .= '<div class="pb-0.5 text-info-600">&#9888;</div>';
return '<div class="pb-0.5 text-info-600">&#9888;</div>';
}
}
public function getUpdatedAt($updated_at)
{
$this->pop .= '<div class="text-xs text-nowrap">'.Carbon::createFromDate($updated_at)->format('H:i').'</div>';
return '<div class="text-xs text-nowrap">'.Carbon::createFromDate($updated_at)->format('H:i').'</div>';
}
public function legend()
{
$part = '<div class="col-span-full font-normal flex justify-end gap-2" style="font-size:10px">';
$part .= '<div class="w-12 bg-green-600/25 rounded py-0.5 px-2">Highest</div>';
$part .= '<div class="w-12 bg-blue-600/25 rounded py-0.5 px-2">Lowest</div>';
$part .= '</div>';
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 = '<div class="grid grid-cols-14 gap-2 m-5 z-100 text-xs text-center">';
$part = '<div class="grid grid-cols-15 gap-2 m-5 mt-1 z-100 text-xs text-center">';
} else {
$this->pop = '<div class="grid grid-cols-12 gap-2 m-5 z-100 text-xs text-center">';
$part = '<div class="grid grid-cols-13 gap-2 m-5 mt-1 z-100 text-xs text-center">';
}
} else {
if ($columns == 6) {
$this->pop = '<div class="grid grid-cols-7 gap-2 m-5 z-100 text-xs text-center">';
$part = '<div class="grid grid-cols-7 gap-2 m-5 mt-1 z-100 text-xs text-center">';
} else {
$this->pop = '<div class="grid grid-cols-6 gap-2 m-5 z-100 text-xs text-center">';
$part = '<div class="grid grid-cols-6 gap-2 m-5 mt-1 z-100 text-xs text-center">';
}
}
$this->pop .= '<div class="col-span-full text-center text-md font-bold mb-2">'.$title.'</div>';
$part .= '<div class="col-span-full text-center text-md font-bold mb-2">'.$title.'</div>';
foreach ($labels as $label) {
$this->pop .= '<div>'.$label.'</div>';
$part .= '<div>'.$label.'</div>';
}
if ($this->size > $this->two_cols_break) {
$this->pop .= '<div></div>';
$part .= '<div></div>';
foreach ($labels as $label) {
$this->pop .= '<div>'.$label.'</div>';
$part .= '<div>'.$label.'</div>';
}
}
return $part;
}
}
Generated
+3 -3
View File
@@ -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"
}