wip
This commit is contained in:
1 parent
e7973f6302
commit
8dba4bed04
1 file changed
+52
-28
@@ -4,61 +4,77 @@ namespace App\Livewire;
|
|||||||
|
|
||||||
use App\Models\Event;
|
use App\Models\Event;
|
||||||
use App\Models\StatistikoEvent;
|
use App\Models\StatistikoEvent;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Schemas\Schema;
|
||||||
use Filament\Widgets\ChartWidget;
|
use Filament\Widgets\ChartWidget;
|
||||||
|
use Filament\Widgets\ChartWidget\Concerns\HasFiltersSchema;
|
||||||
use Illuminate\Contracts\Support\Htmlable;
|
use Illuminate\Contracts\Support\Htmlable;
|
||||||
use Illuminate\Support\HtmlString;
|
use Illuminate\Support\HtmlString;
|
||||||
|
|
||||||
class StatisticEventChart extends ChartWidget
|
class StatisticEventChart extends ChartWidget
|
||||||
{
|
{
|
||||||
|
use HasFiltersSchema;
|
||||||
|
|
||||||
public Event $record;
|
public Event $record;
|
||||||
|
|
||||||
public ?string $filter = 'gls';
|
// protected bool $hasDeferredFilters = true;
|
||||||
|
|
||||||
protected bool $hasDeferredFilters = true;
|
public ?string $filter = 'gls';
|
||||||
|
|
||||||
protected ?string $pollingInterval = null;
|
protected ?string $pollingInterval = null;
|
||||||
|
|
||||||
public function getHeading(): string|Htmlable|null
|
public function getHeading(): string|Htmlable|null
|
||||||
{
|
{
|
||||||
$str = '<div class="flex flex-row gap-4 justify-center bg-gray-300 font-thin">';
|
// $str = '<div class="flex flex-row gap-4 justify-center bg-gray-300 font-thin">';
|
||||||
$str .= '<div>'.$this->record->country->name.' '.$this->record->group->name.'</div>';
|
// $str .= '<div>'.$this->record->country->name.' '.$this->record->group->name.'</div>';
|
||||||
if ($this->record->home->betsapi_image_id) {
|
// if ($this->record->home->betsapi_image_id) {
|
||||||
$str .= ' <img src="https://assets.b365api.com/images/team/m/'.$this->record->home->betsapi_image_id.'.png" class="h-6">';
|
// $str .= ' <img src="https://assets.b365api.com/images/team/m/'.$this->record->home->betsapi_image_id.'.png" class="h-6">';
|
||||||
}
|
// }
|
||||||
$str .= '<div>'.$this->record->home->name.'</div>';
|
// $str .= '<div>'.$this->record->home->name.'</div>';
|
||||||
$str .= '<div>vs</div>';
|
// $str .= '<div>vs</div>';
|
||||||
$str .= '<div>'.$this->record->away->name.'</div>';
|
// $str .= '<div>'.$this->record->away->name.'</div>';
|
||||||
if ($this->record->away->betsapi_image_id) {
|
// if ($this->record->away->betsapi_image_id) {
|
||||||
$str .= ' <img src="https://assets.b365api.com/images/team/m/'.$this->record->away->betsapi_image_id.'.png" class="h-6">';
|
// $str .= ' <img src="https://assets.b365api.com/images/team/m/'.$this->record->away->betsapi_image_id.'.png" class="h-6">';
|
||||||
}
|
// }
|
||||||
$str .= '</div>';
|
// $str .= '</div>';
|
||||||
|
|
||||||
return new HtmlString($str);
|
return new HtmlString($this->record->country->name.' '.$this->record->group->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getFilters(): ?array
|
public function filtersSchema(Schema $schema): Schema
|
||||||
{
|
{
|
||||||
return [
|
return $schema->schema([
|
||||||
'gls' => 'Goals',
|
Select::make('data_mode')
|
||||||
'crn' => 'Corner',
|
->default('gls')
|
||||||
'fls' => 'Committed Fouls',
|
->options([
|
||||||
'ofs' => 'Offsides',
|
'gls' => 'Goals',
|
||||||
'crd' => 'Cards',
|
'crn' => 'Corner',
|
||||||
'snt' => 'Shots on target',
|
'fls' => 'Committed Fouls',
|
||||||
'tsh' => 'TotalShots',
|
'ofs' => 'Offsides',
|
||||||
];
|
'crd' => 'Cards',
|
||||||
|
'snt' => 'Shots on target',
|
||||||
|
'tsh' => 'TotalShots',
|
||||||
|
]),
|
||||||
|
Select::make('claculation_mode')
|
||||||
|
->default('punctual')
|
||||||
|
->options([
|
||||||
|
'punctual' => 'Punctual',
|
||||||
|
'average' => 'Moving average',
|
||||||
|
]),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getData(): array
|
protected function getData(): array
|
||||||
{
|
{
|
||||||
$activeFilter = $this->filter;
|
$data_mode = $this->filters['data_mode'] ?? null;
|
||||||
|
$claculation_mode = $this->filters['claculation_mode'] ?? null;
|
||||||
|
|
||||||
$res = StatistikoEvent::where('league_id', $this->record['competition_group_id'])
|
$res = StatistikoEvent::where('league_id', $this->record['competition_group_id'])
|
||||||
->where('home_id', $this->record['home_id'])
|
->where('home_id', $this->record['home_id'])
|
||||||
->where('away_id', $this->record['away_id'])
|
// ->where('away_id', $this->record['away_id'])
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
switch ($activeFilter) {
|
switch ($data_mode) {
|
||||||
case 'crn':
|
case 'crn':
|
||||||
$h = 'crn_h';
|
$h = 'crn_h';
|
||||||
$a = 'crn_a';
|
$a = 'crn_a';
|
||||||
@@ -130,9 +146,17 @@ class StatisticEventChart extends ChartWidget
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
'plugins' => [
|
||||||
|
'legend' => [
|
||||||
|
'display' => true,
|
||||||
|
'position' => 'top', // Set position to 'top'
|
||||||
|
],
|
||||||
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ], layout: FiltersLayout::AboveContent)
|
||||||
|
|
||||||
protected function getType(): string
|
protected function getType(): string
|
||||||
{
|
{
|
||||||
return 'line';
|
return 'line';
|
||||||
|
|||||||
Reference in new issue
Block a user