statistio popup comparatore wip
This commit is contained in:
1 parent
e6203c366e
commit
e7973f6302
9 files changed
+1172
-4
No files matched your search
@@ -10,6 +10,7 @@ use App\Filament\Tables\Columns\ColumnOdds;
|
||||
use App\Filament\Tables\Columns\ColumnStarttime;
|
||||
use App\Filament\Tables\Columns\EventColumn;
|
||||
use App\Filament\Tables\Columns\MatchIds;
|
||||
use App\Filament\Tables\Columns\StatisticEventColumn;
|
||||
use App\Filament\Tables\Columns\TooltipOdds;
|
||||
use App\Models\ClientGroupList;
|
||||
use App\Models\CompetitionGroup;
|
||||
@@ -37,6 +38,7 @@ use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Filters\Indicator;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -85,6 +87,9 @@ class EventsTable
|
||||
->description(fn ($record) => ucwords($record->group?->name)),
|
||||
|
||||
EventColumn::make('event'),
|
||||
StatisticEventColumn::make('statistic-event')
|
||||
->label('')
|
||||
->alignCenter(),
|
||||
|
||||
TooltipOdds::make('ml')->bettype('odds_2ways')->label('')->visible(fn () => in_array('odds_2ways', self::$bettype_settings)),
|
||||
ColumnOdds::make('odds_2ways')->bettype('odds_2ways')
|
||||
@@ -578,6 +583,16 @@ class EventsTable
|
||||
->recordUrl(null) // disable row click for page
|
||||
->recordAction(null) // disable row click for modal
|
||||
->recordActions([
|
||||
// Action::make('event-statistic')
|
||||
// ->iconButton()
|
||||
// ->modalIcon('phosphor-chart-line')
|
||||
// ->color('gray')
|
||||
// ->modalHeading(fn ($record) => $record->country->name.' - '.$record->group->name)
|
||||
// ->icon('phosphor-chart-line')
|
||||
// ->modalContent(fn ($record): View => view(
|
||||
// 'statistic-event-chart',
|
||||
// ['record' => $record],
|
||||
// )),
|
||||
Action::make('star')
|
||||
->iconButton()
|
||||
->color(function ($record) {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Tables\Columns;
|
||||
|
||||
use Filament\Tables\Columns\Column;
|
||||
|
||||
class StatisticEventColumn extends Column
|
||||
{
|
||||
protected string $view = 'filament.tables.columns.statistic-event-column';
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\Event;
|
||||
use App\Models\StatistikoEvent;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
class StatisticEventChart extends ChartWidget
|
||||
{
|
||||
public Event $record;
|
||||
|
||||
public ?string $filter = 'gls';
|
||||
|
||||
protected bool $hasDeferredFilters = true;
|
||||
|
||||
protected ?string $pollingInterval = null;
|
||||
|
||||
public function getHeading(): string|Htmlable|null
|
||||
{
|
||||
$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>';
|
||||
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 .= '<div>'.$this->record->home->name.'</div>';
|
||||
$str .= '<div>vs</div>';
|
||||
$str .= '<div>'.$this->record->away->name.'</div>';
|
||||
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 .= '</div>';
|
||||
|
||||
return new HtmlString($str);
|
||||
}
|
||||
|
||||
protected function getFilters(): ?array
|
||||
{
|
||||
return [
|
||||
'gls' => 'Goals',
|
||||
'crn' => 'Corner',
|
||||
'fls' => 'Committed Fouls',
|
||||
'ofs' => 'Offsides',
|
||||
'crd' => 'Cards',
|
||||
'snt' => 'Shots on target',
|
||||
'tsh' => 'TotalShots',
|
||||
];
|
||||
}
|
||||
|
||||
protected function getData(): array
|
||||
{
|
||||
$activeFilter = $this->filter;
|
||||
|
||||
$res = StatistikoEvent::where('league_id', $this->record['competition_group_id'])
|
||||
->where('home_id', $this->record['home_id'])
|
||||
->where('away_id', $this->record['away_id'])
|
||||
->get();
|
||||
|
||||
switch ($activeFilter) {
|
||||
case 'crn':
|
||||
$h = 'crn_h';
|
||||
$a = 'crn_a';
|
||||
break;
|
||||
case 'fls':
|
||||
$h = 'fls_h';
|
||||
$a = 'fls_a';
|
||||
break;
|
||||
case 'ofs':
|
||||
$h = 'ofs_h';
|
||||
$a = 'ofs_a';
|
||||
break;
|
||||
case 'crd':
|
||||
$h = 'crd_h';
|
||||
$a = 'crd_a';
|
||||
break;
|
||||
case 'snt':
|
||||
$h = 'snt_h';
|
||||
$a = 'snt_a';
|
||||
break;
|
||||
case 'tsh':
|
||||
$h = 'tsh_h';
|
||||
$a = 'tsh_a';
|
||||
break;
|
||||
|
||||
default:
|
||||
$h = 'gls_h';
|
||||
$a = 'gls_a';
|
||||
break;
|
||||
}
|
||||
|
||||
$starttimes = [];
|
||||
$data_home = [];
|
||||
$data_away = [];
|
||||
foreach ($res as $event) {
|
||||
$data_home[] = $event[$h];
|
||||
$data_away[] = $event[$a];
|
||||
$starttimes[] = $event['starttime']->format('d.m.Y');
|
||||
}
|
||||
|
||||
return [
|
||||
'datasets' => [
|
||||
[
|
||||
'label' => $this->record->home->name,
|
||||
'data' => $data_home,
|
||||
'backgroundColor' => '#155dfc',
|
||||
'borderColor' => '#2b7fff',
|
||||
],
|
||||
[
|
||||
'label' => $this->record->away->name,
|
||||
'data' => $data_away,
|
||||
'backgroundColor' => '#00a63e',
|
||||
'borderColor' => '#00c950',
|
||||
],
|
||||
],
|
||||
'labels' => $starttimes,
|
||||
'scales' => $this->getOptions(),
|
||||
];
|
||||
}
|
||||
|
||||
protected function getOptions(): array
|
||||
{
|
||||
return [
|
||||
'scales' => [
|
||||
'y' => [
|
||||
'ticks' => [
|
||||
'precision' => 0, // Forces integers
|
||||
'beginAtZero' => true,
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
protected function getType(): string
|
||||
{
|
||||
return 'line';
|
||||
}
|
||||
}
|
||||
@@ -69,7 +69,7 @@ class AppServiceProvider extends ServiceProvider
|
||||
'gray' => Color::Zinc,
|
||||
'info' => Color::Blue,
|
||||
'success' => Color::Green,
|
||||
'warning' => Color::Orange,
|
||||
'warning' => Color::Amber,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,6 @@ use Filament\Http\Middleware\Authenticate;
|
||||
use Filament\Http\Middleware\AuthenticateSession;
|
||||
use Filament\Http\Middleware\DisableBladeIconComponents;
|
||||
use Filament\Http\Middleware\DispatchServingFilamentEvent;
|
||||
// use Filament\Pages\Dashboard;
|
||||
use Filament\Panel;
|
||||
use Filament\PanelProvider;
|
||||
use Filament\Support\Enums\Width;
|
||||
|
||||
Reference in new issue
Block a user