wip
This commit is contained in:
1 parent
d30eb76442
commit
01a3f41ec0
6 files changed
+210
-14
No files matched your search
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Statistics;
|
||||
|
||||
use App\Models\StatistikoEvent;
|
||||
|
||||
class EventData
|
||||
{
|
||||
public static function get($filter)
|
||||
{
|
||||
$league_id = (int) $filter['league_id'] ?? 0;
|
||||
$team_id = (int) $filter['team_id'] ?? 0;
|
||||
|
||||
if (! $league_id) {
|
||||
return [];
|
||||
}
|
||||
if (! $team_id) {
|
||||
return [];
|
||||
}
|
||||
|
||||
switch ($filter['team_position']) {
|
||||
case 'home':
|
||||
$res = StatistikoEvent::where('league_id', $league_id)->where('home_id', '=', $team_id)->get();
|
||||
break;
|
||||
|
||||
case 'away':
|
||||
$res = StatistikoEvent::where('league_id', $league_id)->where('away_id', '=', $team_id)->get();
|
||||
break;
|
||||
|
||||
default:
|
||||
$res = StatistikoEvent::where('league_id', $league_id)
|
||||
->where(function ($query) use ($team_id) {
|
||||
$query->where('home_id', '=', $team_id)->orWhere('away_id', '=', $team_id);
|
||||
})->get();
|
||||
break;
|
||||
}
|
||||
|
||||
$datasets = [];
|
||||
$labels = [];
|
||||
|
||||
foreach ($res as $value) {
|
||||
$labels[] = $value['starttime']->format('d. M.y');
|
||||
|
||||
$tmp = [];
|
||||
$tmp['crd_a'] = (int) $value['crd_a'];
|
||||
$tmp['crd_h'] = (int) $value['crd_h'];
|
||||
$tmp['crn_a'] = (int) $value['crn_a'];
|
||||
$tmp['crn_h'] = (int) $value['crn_h'];
|
||||
$tmp['fls_a'] = (int) $value['fls_a'];
|
||||
$tmp['fls_h'] = (int) $value['fls_h'];
|
||||
$tmp['gls_a'] = (int) $value['gls_a'];
|
||||
$tmp['gls_h'] = (int) $value['gls_h'];
|
||||
$tmp['ofs_a'] = (int) $value['ofs_a'];
|
||||
$tmp['ofs_h'] = (int) $value['ofs_h'];
|
||||
$tmp['snt_a'] = (int) $value['snt_a'];
|
||||
$tmp['snt_h'] = (int) $value['snt_h'];
|
||||
$tmp['tsh_a'] = (int) $value['tsh_a'];
|
||||
$tmp['tsh_h'] = (int) $value['tsh_h'];
|
||||
|
||||
$tmp['exp_handicap'] = (float) $value['exp_handicap'];
|
||||
$tmp['exp_total'] = (float) $value['exp_total'];
|
||||
$tmp['exp_away'] = (float) $value['expgoalsaway_value'];
|
||||
$tmp['exp_home'] = (float) $value['expgoalshome_value'];
|
||||
|
||||
$datasets[] = $tmp;
|
||||
}
|
||||
|
||||
return ['lables' => $labels, 'datasets' => $datasets];
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Statistics;
|
||||
|
||||
class StatisticEvents
|
||||
{
|
||||
public static function load($filter)
|
||||
{
|
||||
$data = EventData::get($filter);
|
||||
|
||||
if (! $data) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [];
|
||||
dd($data);
|
||||
|
||||
/*
|
||||
"team_position" => "away"
|
||||
"similar_past_matches" => "none"
|
||||
"statistic_type" => "none"
|
||||
"accuracy" => 0.5
|
||||
"league_id" => "87"
|
||||
"team_id" => null
|
||||
"startDate" => null
|
||||
"endDate" => null
|
||||
"palyer_id" => null
|
||||
|
||||
'sport_id',
|
||||
'league_id',
|
||||
'home_id',
|
||||
'away_id',
|
||||
'starttime',
|
||||
*/
|
||||
|
||||
// $res = StatistikoEvent::where('league_id', $league_id)->get();
|
||||
// $result = DB::connection('mongodb')
|
||||
// ->table('movies')
|
||||
// ->where('league_id', $league_id)
|
||||
// ->orWhere('home_id', $home_id)
|
||||
// ->get();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,13 @@
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Actions\LoadStatisticFixturesLeaguesOptions;
|
||||
use App\Actions\Statistics\StatisticEvents;
|
||||
use App\Filament\Widgets\MovingAverageChart;
|
||||
use App\Filament\Widgets\PunctualChart;
|
||||
use App\Models\Element;
|
||||
use App\Models\StatisticFixtures;
|
||||
use BackedEnum;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Slider;
|
||||
@@ -23,7 +27,20 @@ class Statistic extends BaseDashboard
|
||||
|
||||
protected static ?string $title = 'Statistic';
|
||||
|
||||
protected int|string|array $columnSpan = 'full';
|
||||
protected static array $types = [
|
||||
'gls' => 'Goals',
|
||||
'crn' => 'Corner',
|
||||
'fls' => 'Fouls commited',
|
||||
'ofs' => 'Offside',
|
||||
'crd' => 'Cards',
|
||||
'snt' => 'Shot on target',
|
||||
'tsh' => 'Total shots',
|
||||
];
|
||||
|
||||
public function getColumns(): int|array
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public function filtersForm(Schema $schema): Schema
|
||||
{
|
||||
@@ -77,15 +94,27 @@ class Statistic extends BaseDashboard
|
||||
->live(),
|
||||
Select::make('team_position')
|
||||
->prefixIcon('phosphor-map-pin')
|
||||
->default('home')
|
||||
->suffixAction(
|
||||
Action::make('iconInfo')
|
||||
->color('gray')
|
||||
->icon('phosphor-question')
|
||||
->tooltip('Lorem ipsum dolor sit amet, consetetur sadipscing elitr.')
|
||||
)
|
||||
->default('all')
|
||||
->selectablePlaceholder(false)
|
||||
->options([
|
||||
'all' => 'All',
|
||||
'home' => 'Home',
|
||||
'away' => 'Away',
|
||||
'all' => 'All',
|
||||
]),
|
||||
Select::make('similar_past_matches')
|
||||
->prefixIcon('phosphor-align-center-horizontal')
|
||||
->suffixAction(
|
||||
Action::make('iconInfo')
|
||||
->color('gray')
|
||||
->icon('phosphor-question')
|
||||
->tooltip('Lorem ipsum dolor sit amet, consetetur sadipscing elitr.')
|
||||
)
|
||||
->default('none')
|
||||
->selectablePlaceholder(false)
|
||||
->options([
|
||||
@@ -95,10 +124,16 @@ class Statistic extends BaseDashboard
|
||||
]),
|
||||
Select::make('statistic_type')
|
||||
->prefixIcon('phosphor-cell-signal-full')
|
||||
->suffixAction(
|
||||
Action::make('iconInfo')
|
||||
->color('gray')
|
||||
->icon('phosphor-question')
|
||||
->tooltip('Lorem ipsum dolor sit amet, consetetur sadipscing elitr.')
|
||||
)
|
||||
->default('none')
|
||||
->selectablePlaceholder(false)
|
||||
->options([
|
||||
'gls' => 'Gouls',
|
||||
'gls' => 'Goals',
|
||||
'crn' => 'Corner',
|
||||
'fls' => 'Fouls commited',
|
||||
'ofs' => 'Offside',
|
||||
@@ -117,4 +152,27 @@ class Statistic extends BaseDashboard
|
||||
->pips(),
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getFooterWidgets(): array
|
||||
{
|
||||
|
||||
$data = StatisticEvents::load($this->filters);
|
||||
|
||||
$type = self::$types[$this->filters['statistic_type']];
|
||||
|
||||
// $data = [
|
||||
// 'datasets' => [
|
||||
// [
|
||||
// 'label' => 'test',
|
||||
// 'data' => [0, 10, 5, 2, 21, 32, 45, 74, 65, 45, 77, 89],
|
||||
// ],
|
||||
// ],
|
||||
// 'labels' => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
|
||||
// ];
|
||||
|
||||
return [
|
||||
MovingAverageChart::make(['filters' => $data, 'header' => $type.' Punctual']),
|
||||
PunctualChart::make(['filters' => $data, 'header' => $type.' Moving Avverage']),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets;
|
||||
|
||||
use Filament\Widgets\ChartWidget;
|
||||
|
||||
class MovingAverageChart extends ChartWidget
|
||||
{
|
||||
public ?array $filters = [];
|
||||
|
||||
public ?string $header;
|
||||
|
||||
protected function getData(): array
|
||||
{
|
||||
$this->heading = $this->header;
|
||||
|
||||
return $this->filters;
|
||||
}
|
||||
|
||||
protected function getType(): string
|
||||
{
|
||||
return 'line';
|
||||
}
|
||||
}
|
||||
@@ -4,15 +4,17 @@ namespace App\Filament\Widgets;
|
||||
|
||||
use Filament\Widgets\ChartWidget;
|
||||
|
||||
class StatisticChart extends ChartWidget
|
||||
class PunctualChart extends ChartWidget
|
||||
{
|
||||
protected ?string $heading = 'Statistic Chart';
|
||||
public ?array $filters = [];
|
||||
|
||||
public ?string $header;
|
||||
|
||||
protected function getData(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
$this->heading = $this->header;
|
||||
|
||||
return $this->filters;
|
||||
}
|
||||
|
||||
protected function getType(): string
|
||||
@@ -5,7 +5,6 @@ namespace App\Providers\Filament;
|
||||
// use Agencetwogether\HooksHelper\HooksHelperPlugin;
|
||||
use App\Filament\Exports\BetfairExporter;
|
||||
use App\Filament\Pages\Statistic;
|
||||
use App\Filament\Widgets\StatisticChart;
|
||||
use App\Http\Middleware\RecordUserActivity;
|
||||
use Awcodes\LightSwitch\Enums\Alignment;
|
||||
use Awcodes\LightSwitch\LightSwitchPlugin;
|
||||
@@ -85,7 +84,7 @@ class AdminPanelProvider extends PanelProvider
|
||||
->viteTheme('resources/css/filament/admin/theme.css')
|
||||
->discoverResources(in: app_path('Filament/Resources'), for: 'App\Filament\Resources')
|
||||
->discoverPages(in: app_path('Filament/Pages'), for: 'App\Filament\Pages')
|
||||
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\Filament\Widgets')
|
||||
// ->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\Filament\Widgets')
|
||||
->discoverClusters(in: app_path('Filament/Clusters'), for: 'App\\Filament\\Clusters')
|
||||
->maxContentWidth(Width::ScreenTwoExtraLarge)
|
||||
->breadcrumbs(false)
|
||||
@@ -100,9 +99,7 @@ class AdminPanelProvider extends PanelProvider
|
||||
->pages([
|
||||
Statistic::class,
|
||||
])
|
||||
->widgets([
|
||||
StatisticChart::class,
|
||||
])
|
||||
->widgets([])
|
||||
->middleware([
|
||||
EncryptCookies::class,
|
||||
AddQueuedCookiesToResponse::class,
|
||||
|
||||
Reference in new issue
Block a user