diff --git a/NOTES.md b/NOTES.md index 19d0ce36..6fcbd034 100644 --- a/NOTES.md +++ b/NOTES.md @@ -4,7 +4,7 @@ https://github.com/christophrumpel/laravel-import-million-rows https://github.com/spatie/simple-excel https://csv.thephpleague.com/ -mongodb +MONGODB model schema https://www.mongodb.com/docs/drivers/php/laravel-mongodb/v4.x/eloquent-models/schema-builder/ @@ -12,4 +12,8 @@ upsert https://medium.com/@kaamil.mirza.2002/how-i-learned-to-upsert-millions-of-documents-into-mongodb-with-minimal-overhead-8b7f9404a70c https://www.mongodb.com/docs/manual/reference/method/Bulk.find.upsert/ -https://www.mongodb.com/docs/drivers/php/laravel-mongodb/current/fundamentals/write-operations/ \ No newline at end of file +https://www.mongodb.com/docs/drivers/php/laravel-mongodb/current/fundamentals/write-operations/ + +CHART +https://icehouse-ventures.github.io/laravel-chartjs/ +https://www.chartjs.org/docs/latest/configuration/interactions.html \ No newline at end of file diff --git a/app/Filament/Resources/Events/Tables/EventsTable.php b/app/Filament/Resources/Events/Tables/EventsTable.php index ebc38da3..c956e516 100644 --- a/app/Filament/Resources/Events/Tables/EventsTable.php +++ b/app/Filament/Resources/Events/Tables/EventsTable.php @@ -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) { diff --git a/app/Filament/Tables/Columns/StatisticEventColumn.php b/app/Filament/Tables/Columns/StatisticEventColumn.php new file mode 100644 index 00000000..83cd36df --- /dev/null +++ b/app/Filament/Tables/Columns/StatisticEventColumn.php @@ -0,0 +1,10 @@ +'; + $str .= '
';
+ }
+ $str .= '
';
+ }
+ $str .= '';
+
+ 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';
+ }
+}
diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php
index 49a7d582..3b89f815 100644
--- a/app/Providers/AppServiceProvider.php
+++ b/app/Providers/AppServiceProvider.php
@@ -69,7 +69,7 @@ class AppServiceProvider extends ServiceProvider
'gray' => Color::Zinc,
'info' => Color::Blue,
'success' => Color::Green,
- 'warning' => Color::Orange,
+ 'warning' => Color::Amber,
]);
}
}
diff --git a/app/Providers/Filament/AdminPanelProvider.php b/app/Providers/Filament/AdminPanelProvider.php
index 118f4f3e..157688dc 100644
--- a/app/Providers/Filament/AdminPanelProvider.php
+++ b/app/Providers/Filament/AdminPanelProvider.php
@@ -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;
diff --git a/public/js/app/components/apexcharts.js b/public/js/app/components/apexcharts.js
new file mode 100644
index 00000000..80b0c0a7
--- /dev/null
+++ b/public/js/app/components/apexcharts.js
@@ -0,0 +1,967 @@
+var Ci=(u,t)=>()=>(t||u((t={exports:{}}).exports,t),t.exports);var vi=Ci((Ht,Mt)=>{var fa=200,si="__lodash_hash_undefined__",ga=800,pa=16,ii=9007199254740991,ai="[object Arguments]",ua="[object Array]",xa="[object AsyncFunction]",ba="[object Boolean]",ma="[object Date]",ya="[object Error]",oi="[object Function]",wa="[object GeneratorFunction]",va="[object Map]",Aa="[object Number]",Ca="[object Null]",ri="[object Object]",Sa="[object Proxy]",ka="[object RegExp]",La="[object Set]",Da="[object String]",Ta="[object Undefined]",Ma="[object WeakMap]",Pa="[object ArrayBuffer]",Ea="[object DataView]",Fa="[object Float32Array]",Xa="[object Float64Array]",Ra="[object Int8Array]",_a="[object Int16Array]",Ia="[object Int32Array]",Ya="[object Uint8Array]",Na="[object Uint8ClampedArray]",za="[object Uint16Array]",Oa="[object Uint32Array]",Ba=/[\\^$.*+?()[\]{}|]/g,Ha=/^\[object .+?Constructor\]$/,Wa=/^(?:0|[1-9]\d*)$/,U={};U[Fa]=U[Xa]=U[Ra]=U[_a]=U[Ia]=U[Ya]=U[Na]=U[za]=U[Oa]=!0;U[ai]=U[ua]=U[Pa]=U[ba]=U[Ea]=U[ma]=U[ya]=U[oi]=U[va]=U[Aa]=U[ri]=U[ka]=U[La]=U[Da]=U[Ma]=!1;var ni=typeof global=="object"&&global&&global.Object===Object&&global,Ga=typeof self=="object"&&self&&self.Object===Object&&self,$t=ni||Ga||Function("return this")(),li=typeof Ht=="object"&&Ht&&!Ht.nodeType&&Ht,Wt=li&&typeof Mt=="object"&&Mt&&!Mt.nodeType&&Mt,ci=Wt&&Wt.exports===li,bs=ci&&ni.process,Us=(function(){try{var u=Wt&&Wt.require&&Wt.require("util").types;return u||bs&&bs.binding&&bs.binding("util")}catch{}})(),qs=Us&&Us.isTypedArray;function $a(u,t,e){switch(e.length){case 0:return u.call(t);case 1:return u.call(t,e[0]);case 2:return u.call(t,e[0],e[1]);case 3:return u.call(t,e[0],e[1],e[2])}return u.apply(t,e)}function Va(u,t){for(var e=-1,s=Array(u);++e-1}function uo(u,t){var e=this.__data__,s=ge(e,u);return s<0?(++this.size,e.push([u,t])):e[s][1]=t,this}dt.prototype.clear=ho;dt.prototype.delete=fo;dt.prototype.get=go;dt.prototype.has=po;dt.prototype.set=uo;function Pt(u){var t=-1,e=u==null?0:u.length;for(this.clear();++t
+ @endif
+
+ @endif
+