statistiko dedicated page wip
This commit is contained in:
1 parent
cba90136a5
commit
1b5282d61d
14 files changed
+482
-213
No files matched your search
+11
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Statistic\Resources\StatisticEvents\Pages;
|
||||
|
||||
use App\Filament\Clusters\Statistic\Resources\StatisticEvents\StatisticEventsResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateStatisticEvents extends CreateRecord
|
||||
{
|
||||
protected static string $resource = StatisticEventsResource::class;
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Statistic\Resources\StatisticEvents\Pages;
|
||||
|
||||
use App\Filament\Clusters\Statistic\Resources\StatisticEvents\StatisticEventsResource;
|
||||
// use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditStatisticEvents extends EditRecord
|
||||
{
|
||||
protected static string $resource = StatisticEventsResource::class;
|
||||
|
||||
// protected function getHeaderActions(): array
|
||||
// {
|
||||
// return [
|
||||
// DeleteAction::make(),
|
||||
// ];
|
||||
// }
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Statistic\Resources\StatisticEvents\Pages;
|
||||
|
||||
use App\Filament\Clusters\Statistic\Resources\StatisticEvents\StatisticEventsResource;
|
||||
// use Filament\Actions\CreateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListStatisticEvents extends ListRecords
|
||||
{
|
||||
protected static string $resource = StatisticEventsResource::class;
|
||||
|
||||
// protected function getHeaderActions(): array
|
||||
// {
|
||||
// return [
|
||||
// CreateAction::make(),
|
||||
// ];
|
||||
// }
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Statistic\Resources\StatisticEvents\Schemas;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class StatisticEventsForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Statistic\Resources\StatisticEvents;
|
||||
|
||||
use App\Filament\Clusters\Statistic\Resources\StatisticEvents\Pages\ListStatisticEvents;
|
||||
use App\Filament\Clusters\Statistic\Resources\StatisticEvents\Schemas\StatisticEventsForm;
|
||||
use App\Filament\Clusters\Statistic\Resources\StatisticEvents\Tables\StatisticEventsTable;
|
||||
use App\Filament\Clusters\Statistic\StatisticCluster;
|
||||
use App\Models\StatistikoEvent;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class StatisticEventsResource extends Resource
|
||||
{
|
||||
protected static ?string $model = StatistikoEvent::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = 'phosphor-chart-line-up';
|
||||
|
||||
protected static ?string $navigationLabel = 'Statistic Events';
|
||||
|
||||
protected static ?string $modelLabel = 'Statistic Events';
|
||||
|
||||
protected static ?int $navigationSort = 1;
|
||||
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Statistic Events';
|
||||
|
||||
protected static ?string $cluster = StatisticCluster::class;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return StatisticEventsForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return StatisticEventsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListStatisticEvents::route('/'),
|
||||
];
|
||||
}
|
||||
}
|
||||
+352
@@ -0,0 +1,352 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Statistic\Resources\StatisticEvents\Tables;
|
||||
|
||||
use App\Models\CompetitionGroup;
|
||||
use App\Models\Country;
|
||||
use App\Models\Event;
|
||||
use App\Models\Sport;
|
||||
use CodeWithKyrian\FilamentDateRange\Forms\Components\DateRangePicker;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Filters\Indicator;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
class StatisticEventsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->striped()
|
||||
->columns([
|
||||
IconColumn::make('sport_id')
|
||||
->label('')
|
||||
->icon(fn (string $state): string => match ($state) {
|
||||
'1' => 'icon-soccerball',
|
||||
'2' => 'icon-icehockey',
|
||||
'3' => 'icon-basketball',
|
||||
'5' => 'icon-tennisball',
|
||||
}),
|
||||
TextColumn::make('league.name'),
|
||||
TextColumn::make('starttime')->dateTime('M j, Y')->label('Date'),
|
||||
TextColumn::make('home.name')->color('primary'),
|
||||
TextColumn::make('away.name')->color('success'),
|
||||
])
|
||||
->filters([
|
||||
Filter::make('events')
|
||||
->columns(5)->columnSpan(5)
|
||||
->schema([
|
||||
Select::make('sport_id')
|
||||
->default(1)
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->label('Sport')
|
||||
->options(Sport::whereIn('id', [1, 2, 3, 5])->pluck('name', 'id')),
|
||||
Select::make(name: 'country_id')
|
||||
->hidden(fn (Get $get) => $get('sport_id') == 5)
|
||||
->placeholder('Country')
|
||||
->prefixIcon('phosphor-flag')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->multiple()
|
||||
->searchable()
|
||||
->preload()
|
||||
->options(function (Get $get) {
|
||||
$res = Event::where('has_markets', 1)
|
||||
->where('sport_id', $get('sport_id'))
|
||||
->where('starttime', '>=', Carbon::now())
|
||||
->groupBy('country_id')
|
||||
->pluck('country_id')->toArray();
|
||||
|
||||
return Country::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id');
|
||||
})
|
||||
->live()
|
||||
->reactive()
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('competition_group_id', null);
|
||||
}),
|
||||
Select::make('competition_group_id')
|
||||
->hidden(fn (Get $get) => $get('sport_id') == 5)
|
||||
->placeholder('League')
|
||||
->prefixIcon('phosphor-trophy')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->multiple()
|
||||
->searchable()
|
||||
->options(function (Get $get) {
|
||||
$country_id = $get('country_id') ?? 0;
|
||||
if ($country_id) {
|
||||
$res = Event::with('country')
|
||||
->with('competition_group')
|
||||
->where('sport_id', $get('sport_id'))
|
||||
->whereIn('country_id', $country_id)
|
||||
->where('starttime', '>', Carbon::now())
|
||||
->groupBy('competition_group_id')->get();
|
||||
} else {
|
||||
$res = Event::with('country')
|
||||
->with('competition_group')
|
||||
->where('sport_id', $get('sport_id'))
|
||||
->where('starttime', '>', Carbon::now())
|
||||
->groupBy('competition_group_id')->get();
|
||||
}
|
||||
|
||||
$arr = [];
|
||||
foreach ($res as $val) {
|
||||
$arr[$val->competition_group_id] = $val->country?->name.' '.$val->competition_group?->name;
|
||||
}
|
||||
asort($arr);
|
||||
|
||||
return $arr;
|
||||
})
|
||||
->live(),
|
||||
Select::make('competition_group_id')
|
||||
->visible(fn (Get $get) => $get('sport_id') == 5)
|
||||
->placeholder('Tournament')
|
||||
->prefixIcon('phosphor-trophy')
|
||||
->hiddenLabel()
|
||||
->label('')
|
||||
->multiple()
|
||||
->searchable()
|
||||
->options(function () {
|
||||
$res = Event::with('competition_group')
|
||||
->where('sport_id', 5)
|
||||
->where('starttime', '>', Carbon::now())
|
||||
->groupBy('competition_group_id')
|
||||
->get();
|
||||
$arr = [];
|
||||
foreach ($res as $val) {
|
||||
$arr[$val->competition_group_id] = $val->competition_group->name;
|
||||
}
|
||||
// asort($arr);
|
||||
|
||||
return $arr;
|
||||
})
|
||||
->live(),
|
||||
|
||||
DatePicker::make('starttime_from')
|
||||
->prefix(fn () => new HtmlString('<string class="text-info-500">From</string>'))
|
||||
->displayFormat('d M Y')
|
||||
->hiddenLabel()
|
||||
->label(''),
|
||||
DatePicker::make('starttime_to')
|
||||
->prefix(fn () => new HtmlString('<string class="text-success-500">To:</string>'))
|
||||
->displayFormat('d M Y')
|
||||
->hiddenLabel()
|
||||
->label(''),
|
||||
])
|
||||
->query(function (Builder $query, array $data): Builder {
|
||||
return $query->when(
|
||||
$data['sport_id'],
|
||||
function (Builder $query, $sport_id) {
|
||||
$query->where('sport_id', (int) $sport_id);
|
||||
}
|
||||
)->when(
|
||||
$data['starttime_from'],
|
||||
function (Builder $query, $starttime_from) {
|
||||
if (isset($starttime_from)) {
|
||||
$from = Carbon::createFromDate($starttime_from);
|
||||
|
||||
return $query->where('starttime', '>=', $starttime_from);
|
||||
}
|
||||
}
|
||||
)->when(
|
||||
$data['starttime_to'],
|
||||
function (Builder $query, $starttime_to) {
|
||||
if (isset($starttime_to)) {
|
||||
$to = Carbon::createFromDate($starttime_to);
|
||||
|
||||
return $query->where('starttime', '<=', $starttime_to);
|
||||
}
|
||||
}
|
||||
);
|
||||
})->indicateUsing(function (array $data): array {
|
||||
$indicators = [];
|
||||
|
||||
if ($data['starttime_from'] ?? null) {
|
||||
$starttime_from = $data['starttime_from'];
|
||||
if ($starttime_from ?? null) {
|
||||
$text = Carbon::parse($starttime_from)->format('d. M. Y');
|
||||
$indicators[] = Indicator::make('From: '.$text)->removeField('starttime_from')->color('info');
|
||||
}
|
||||
}
|
||||
if ($data['starttime_to'] ?? null) {
|
||||
$starttime_to = $data['starttime_to'];
|
||||
if ($starttime_to ?? null) {
|
||||
$text = Carbon::parse($starttime_to)->format('d. M. Y');
|
||||
$indicators[] = Indicator::make('To: '.$text)->removeField('starttime_to')->color('success');
|
||||
}
|
||||
}
|
||||
|
||||
// if ($data['competition_group_id'] ?? null) {
|
||||
// $competition_groups = CompetitionGroup::whereIn('id', $data['competition_group_id'])->pluck('name')->toArray();
|
||||
// if (count($competition_groups) > 1) {
|
||||
// $indicators[] = Indicator::make(implode(', ', $competition_groups))->removeField('competition_group_id')->color('info');
|
||||
// } else {
|
||||
// $indicators[] = Indicator::make($competition_groups[0])->removeField('competition_group_id')->color('info')->color('info');
|
||||
// }
|
||||
// }
|
||||
|
||||
return $indicators;
|
||||
}),
|
||||
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
// ->filters([
|
||||
// Filter::make('events')
|
||||
// ->columns(7)->columnSpan(7)
|
||||
// ->schema([
|
||||
// Select::make('sport_id')
|
||||
// ->default(1)
|
||||
// ->hiddenLabel()
|
||||
// ->label('')
|
||||
// ->label('Sport')
|
||||
// ->options(Sport::where('is_active', 1)->pluck('name', 'id')),
|
||||
// // Select::make('competition_group_id')
|
||||
// // ->hidden(fn (Get $get) => $get('sport_id') == 5)
|
||||
// // ->placeholder('League')
|
||||
// // ->prefixIcon('phosphor-trophy')
|
||||
// // ->hiddenLabel()
|
||||
// // ->label('')
|
||||
// // ->multiple()
|
||||
// // ->searchable()
|
||||
// // ->options(function (Get $get) {
|
||||
// // $res = Event::where('has_markets', 1)
|
||||
// // ->with('country')
|
||||
// // ->with('competition_group')
|
||||
// // ->where('sport_id', $get('sport_id'))
|
||||
// // ->where('starttime', '>', Carbon::now())
|
||||
// // ->whereIn('country_id', $get('country_id'))
|
||||
// // ->groupBy('competition_group_id')->get();
|
||||
|
||||
// // $arr = [];
|
||||
// // foreach ($res as $val) {
|
||||
// // $arr[$val->competition_group_id] = $val->country?->name.' '.$val->competition_group?->name;
|
||||
// // }
|
||||
// // asort($arr);
|
||||
|
||||
// // return $arr;
|
||||
// // })
|
||||
// // ->live(),
|
||||
// // Select::make('competition_group_id')
|
||||
// // ->visible(fn (Get $get) => $get('sport_id') == 5)
|
||||
// // ->placeholder('Tournament')
|
||||
// // ->prefixIcon('phosphor-trophy')
|
||||
// // ->hiddenLabel()
|
||||
// // ->label('')
|
||||
// // ->multiple()
|
||||
// // ->searchable()
|
||||
// // ->options(function () {
|
||||
// // $res = Event::where('has_markets', 1)
|
||||
// // ->with('competition_group')
|
||||
// // ->where('sport_id', auth()->user()->sport_id)
|
||||
// // ->where('starttime', '>', Carbon::now())
|
||||
// // ->groupBy('competition_group_id')
|
||||
// // ->get();
|
||||
// // $arr = [];
|
||||
// // foreach ($res as $val) {
|
||||
// // $arr[$val->competition_group_id] = $val->competition_group->name;
|
||||
// // }
|
||||
// // asort($arr);
|
||||
|
||||
// // return $arr;
|
||||
// // })
|
||||
// // ->live(),
|
||||
|
||||
// // DateRangePicker::make('starttime_period')
|
||||
// // ->columnSpan(2)
|
||||
// // ->displayFormat('d M Y')
|
||||
// // ->minDate(now())
|
||||
// // ->hiddenLabel()
|
||||
// // ->label('')
|
||||
// // ->live(),
|
||||
// ]),
|
||||
// // ->query(function (Builder $query, array $data): Builder {
|
||||
// // return $query->when(
|
||||
// // $data['sport_id'],
|
||||
// // function (Builder $query, $sport_id) {
|
||||
// // $query->where('sport_id', $sport_id);
|
||||
// // }
|
||||
|
||||
// // )->when(
|
||||
// // $data['competition_group_id'],
|
||||
// // fn (Builder $query, $competition_group_id) => $query->whereIn('sport_id', $competition_group_id)
|
||||
|
||||
// // )->when(
|
||||
// // $data['starttime_period'],
|
||||
// // function (Builder $query, $starttime_period) {
|
||||
|
||||
// // // dd($starttime_period);
|
||||
|
||||
// // if (isset($starttime_period['start']) && isset($starttime_period['end'])) {
|
||||
// // $from = Carbon::createFromDate($starttime_period['start']);
|
||||
// // $end = Carbon::createFromDate($starttime_period['end']);
|
||||
|
||||
// // return $query
|
||||
// // ->where('starttime', '>=', $from)
|
||||
// // ->where('starttime', '<=', $end);
|
||||
// // } elseif (isset($starttime_period['start'])) {
|
||||
// // $from = Carbon::createFromDate($starttime_period['start']);
|
||||
|
||||
// // return $query
|
||||
// // ->where('starttime', '>=', $from);
|
||||
// // } elseif (isset($starttime_period['end'])) {
|
||||
// // $end = Carbon::createFromDate($starttime_period['end']);
|
||||
|
||||
// // return $query
|
||||
// // ->where('starttime', '<=', $end);
|
||||
// // }
|
||||
// // }
|
||||
// // );
|
||||
// // })->indicateUsing(function (array $data): array {
|
||||
// // $indicators = [];
|
||||
|
||||
// // if ($data['starttime_period'] ?? null) {
|
||||
// // $span = $data['starttime_period'];
|
||||
// // $text = '';
|
||||
// // if ($span['start'] ?? null) {
|
||||
// // $text .= Carbon::parse($span['start'])->format('d. M.');
|
||||
// // }
|
||||
// // if ($span['end'] ?? null) {
|
||||
// // $text .= ' - '.Carbon::parse($span['end'])->format('d. M.');
|
||||
// // }
|
||||
// // if ($text) {
|
||||
// // $indicators[] = Indicator::make($text)->removeField('starttime_period.start')->color('info');
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// // if ($data['competition_group_id'] ?? null) {
|
||||
// // $competition_groups = CompetitionGroup::whereIn('id', $data['competition_group_id'])->pluck('name')->toArray();
|
||||
// // if (count($competition_groups) > 1) {
|
||||
// // $indicators[] = Indicator::make(implode(', ', $competition_groups))->removeField('competition_group_id')->color('info');
|
||||
// // } else {
|
||||
// // $indicators[] = Indicator::make($competition_groups[0])->removeField('competition_group_id')->color('info')->color('info');
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// // return $indicators;
|
||||
// // }),
|
||||
// ], layout: FiltersLayout::AboveContent)
|
||||
// ->deferFilters(false)
|
||||
// ->hiddenFilterIndicators(false)
|
||||
// ->persistFiltersInSession()
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\Statistic;
|
||||
|
||||
use BackedEnum;
|
||||
use Filament\Clusters\Cluster;
|
||||
use Filament\Pages\Enums\SubNavigationPosition;
|
||||
|
||||
class StatisticCluster extends Cluster
|
||||
{
|
||||
protected static string|BackedEnum|null $navigationIcon = 'phosphor-chart-line-up';
|
||||
|
||||
protected static ?SubNavigationPosition $subNavigationPosition = SubNavigationPosition::Top;
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
}
|
||||
@@ -9,5 +9,5 @@ class UserCluster extends Cluster
|
||||
{
|
||||
protected static string|BackedEnum|null $navigationIcon = 'phosphor-user';
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
protected static ?int $navigationSort = 4;
|
||||
}
|
||||
@@ -23,7 +23,7 @@ class EventMapper extends Page
|
||||
|
||||
protected ?string $heading = '';
|
||||
|
||||
protected static ?int $navigationSort = 2; // Smaller number = higher up
|
||||
protected static ?int $navigationSort = 3; // Smaller number = higher up
|
||||
|
||||
// protected static ?int $navigationSort = 100;
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ 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;
|
||||
@@ -87,9 +86,6 @@ 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')
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Tables\Columns;
|
||||
|
||||
use Filament\Tables\Columns\Column;
|
||||
|
||||
class StatisticEventColumn extends Column
|
||||
{
|
||||
protected string $view = 'filament.tables.columns.statistic-event-column';
|
||||
}
|
||||
@@ -1,164 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Livewire;
|
||||
|
||||
use App\Models\Event;
|
||||
use App\Models\StatistikoEvent;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
use Filament\Widgets\ChartWidget\Concerns\HasFiltersSchema;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
class StatisticEventChart extends ChartWidget
|
||||
{
|
||||
use HasFiltersSchema;
|
||||
|
||||
public Event $record;
|
||||
|
||||
// protected bool $hasDeferredFilters = true;
|
||||
|
||||
public ?string $filter = 'gls';
|
||||
|
||||
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($this->record->country->name.' '.$this->record->group->name);
|
||||
}
|
||||
|
||||
public function filtersSchema(Schema $schema): Schema
|
||||
{
|
||||
return $schema->schema([
|
||||
Select::make('data_mode')
|
||||
->default('gls')
|
||||
->options([
|
||||
'gls' => 'Goals',
|
||||
'crn' => 'Corner',
|
||||
'fls' => 'Committed Fouls',
|
||||
'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
|
||||
{
|
||||
$data_mode = $this->filters['data_mode'] ?? null;
|
||||
$claculation_mode = $this->filters['claculation_mode'] ?? null;
|
||||
|
||||
$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 ($data_mode) {
|
||||
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,
|
||||
],
|
||||
],
|
||||
],
|
||||
'plugins' => [
|
||||
'legend' => [
|
||||
'display' => true,
|
||||
'position' => 'top', // Set position to 'top'
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
// ], layout: FiltersLayout::AboveContent)
|
||||
|
||||
protected function getType(): string
|
||||
{
|
||||
return 'line';
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
<div>
|
||||
<x-filament::section icon="phosphor-trophy">
|
||||
<x-slot name="heading">
|
||||
<div>{{ $record->country->name }} {{ $record->group->name }}</div>
|
||||
<div class="flex flex-row gap-2 justify-center items-center">
|
||||
@if ($record->home->betsapi_image_id)
|
||||
<img src="https://assets.b365api.com/images/team/m/{{ $record->home->betsapi_image_id }}.png"
|
||||
class="h-6">
|
||||
@endif
|
||||
<div>{{ $record->home->name }}</div>
|
||||
<div>vs</div>
|
||||
<div>{{ $record->away->name }}</div>
|
||||
@if ($record->away->betsapi_image_id)
|
||||
<img src="https://assets.b365api.com/images/team/m/{{ $record->away->betsapi_image_id }}.png"
|
||||
class="h-6">
|
||||
@endif
|
||||
</div>
|
||||
</x-slot>
|
||||
<div class="flex flex-row gap-4 my-0">
|
||||
|
||||
|
||||
</div>
|
||||
</x-filament::section>
|
||||
|
||||
@livewire(\App\Livewire\StatisticEventChart::class)
|
||||
</div>
|
||||
@@ -1,7 +0,0 @@
|
||||
<x-filament::modal width="5xl">
|
||||
<x-slot name="trigger">
|
||||
<x-filament::icon-button icon="phosphor-chart-line" color="gray" size="md" tooltip="Statistic event" />
|
||||
</x-slot>
|
||||
|
||||
@livewire('statistic-event-chart', ['record' => $record])
|
||||
</x-filament::modal>
|
||||
Reference in new issue
Block a user