55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Tables\Columns;
|
|
|
|
use Filament\Tables\Columns\Column;
|
|
|
|
class Column3way extends Column
|
|
{
|
|
protected string $view = 'filament.tables.columns.column_3way';
|
|
|
|
protected ?array $bookmakers;
|
|
|
|
protected ?bool $has_data;
|
|
|
|
public function bookmakers(?array $bookmakers): static
|
|
{
|
|
array_unshift($bookmakers, auth()->user()->bookmaker_id);
|
|
|
|
$this->bookmakers = $bookmakers;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function getBookmaker(): ?array
|
|
{
|
|
return $this->bookmakers;
|
|
}
|
|
|
|
public function loadData($record)
|
|
{
|
|
$this->has_data = count($record->odds_3way) ? true : false;
|
|
|
|
$tmp = [];
|
|
$tmp['max_h3w'] = $record->odds_3way->max('h3w');
|
|
$tmp['min_h3w'] = $record->odds_3way->min('h3w');
|
|
$tmp['max_d3w'] = $record->odds_3way->max('d3w');
|
|
$tmp['min_d3w'] = $record->odds_3way->min('d3w');
|
|
$tmp['max_a3w'] = $record->odds_3way->max('a3w');
|
|
$tmp['min_a3w'] = $record->odds_3way->min('a3w');
|
|
|
|
foreach ($record->odds_3way as $key => $value) {
|
|
if ($value->h3w == $tmp['max_h3w']) {
|
|
$record->odds_3way->key->max_h3w = true;
|
|
} else {
|
|
$record->odds_3way->key->max_h3w = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
public function hasData()
|
|
{
|
|
return $this->has_data;
|
|
}
|
|
}
|