diff --git a/app/Filament/Clusters/Statistic/Resources/StatisticEvents/Pages/CreateStatisticEvents.php b/app/Filament/Clusters/Statistic/Resources/StatisticEvents/Pages/CreateStatisticEvents.php
new file mode 100644
index 00000000..7771b26e
--- /dev/null
+++ b/app/Filament/Clusters/Statistic/Resources/StatisticEvents/Pages/CreateStatisticEvents.php
@@ -0,0 +1,11 @@
+components([
+ //
+ ]);
+ }
+}
diff --git a/app/Filament/Clusters/Statistic/Resources/StatisticEvents/StatisticEventsResource.php b/app/Filament/Clusters/Statistic/Resources/StatisticEvents/StatisticEventsResource.php
new file mode 100644
index 00000000..2e368088
--- /dev/null
+++ b/app/Filament/Clusters/Statistic/Resources/StatisticEvents/StatisticEventsResource.php
@@ -0,0 +1,47 @@
+ ListStatisticEvents::route('/'),
+ ];
+ }
+}
diff --git a/app/Filament/Clusters/Statistic/Resources/StatisticEvents/Tables/StatisticEventsTable.php b/app/Filament/Clusters/Statistic/Resources/StatisticEvents/Tables/StatisticEventsTable.php
new file mode 100644
index 00000000..ff8acc7b
--- /dev/null
+++ b/app/Filament/Clusters/Statistic/Resources/StatisticEvents/Tables/StatisticEventsTable.php
@@ -0,0 +1,352 @@
+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('
';
- // }
- // $str .= '
';
- // }
- // $str .= '';
-
- 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';
- }
-}
diff --git a/resources/views/components/statistic-event-chart.blade.php b/resources/views/components/statistic-event-chart.blade.php
deleted file mode 100644
index 15f02094..00000000
--- a/resources/views/components/statistic-event-chart.blade.php
+++ /dev/null
@@ -1,26 +0,0 @@
-
- @endif
-
- @endif
-