statistic on separate page wip
This commit is contained in:
1 parent
ad36ba555f
commit
422681df01
34 files changed
+660
-734
No files matched your search
+11
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\StatisticFixtures\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\StatisticFixtures\StatisticFixturesResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateStatisticFixtures extends CreateRecord
|
||||
{
|
||||
protected static string $resource = StatisticFixturesResource::class;
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\StatisticFixtures\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\StatisticFixtures\StatisticFixturesResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditStatisticFixtures extends EditRecord
|
||||
{
|
||||
protected static string $resource = StatisticFixturesResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\StatisticFixtures\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\StatisticFixtures\StatisticFixturesResource;
|
||||
use App\Models\StatistikoEvent;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListStatisticFixtures extends ListRecords
|
||||
{
|
||||
protected static string $resource = StatisticFixturesResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('delete_played')
|
||||
->icon('phosphor-trash')
|
||||
->requiresConfirmation()
|
||||
->color('danger')
|
||||
->action(function () {
|
||||
StatistikoEvent::where('starttime', '<', now()->subHour())->delete();
|
||||
}),
|
||||
];
|
||||
}
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\StatisticFixtures\Schemas;
|
||||
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class StatisticFixturesForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('exp_home')->required(),
|
||||
TextInput::make('exp_away')->required(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\StatisticFixtures;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\StatisticFixtures\Pages\ListStatisticFixtures;
|
||||
use App\Filament\Clusters\StaticData\Resources\StatisticFixtures\Schemas\StatisticFixturesForm;
|
||||
use App\Filament\Clusters\StaticData\Resources\StatisticFixtures\Tables\StatisticFixturesTable;
|
||||
use App\Filament\Clusters\StaticData\StaticDataCluster;
|
||||
use App\Models\StatisticFixtures;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
use UnitEnum;
|
||||
|
||||
class StatisticFixturesResource extends Resource
|
||||
{
|
||||
protected static ?string $model = StatisticFixtures::class;
|
||||
|
||||
protected static ?string $navigationLabel = 'Fixtures';
|
||||
|
||||
protected static ?string $modelLabel = 'Fixtures';
|
||||
|
||||
protected static string|UnitEnum|null $navigationGroup = 'Statistiko';
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return StatisticFixturesForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return StatisticFixturesTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListStatisticFixtures::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\StatisticFixtures\Tables;
|
||||
|
||||
use App\Models\CompetitionGroup;
|
||||
use App\Models\StatisticFixtures;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class StatisticFixturesTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->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')
|
||||
->label('League')
|
||||
->searchable()
|
||||
->wrap()
|
||||
->hidden(fn () => auth()->user()->sport_id == 5)
|
||||
->description(fn ($record) => ucwords($record->league?->country->name)),
|
||||
TextColumn::make('starttime')->dateTime('M j, Y')->label('Date'),
|
||||
TextColumn::make('home.name')->color('primary')->searchable(),
|
||||
TextColumn::make('away.name')->color('success')->searchable(),
|
||||
// TextColumn::make('exp_home')->alignCenter()->numeric(),
|
||||
// TextColumn::make('exp_away')->alignCenter()->numeric(),
|
||||
TextColumn::make('updated_at')->alignCenter()->date(),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('league_id')
|
||||
->options(function () {
|
||||
$res = StatisticFixtures::where('sport_id', 1)
|
||||
->groupBy('league_id')
|
||||
->pluck('league_id')->toArray();
|
||||
|
||||
return CompetitionGroup::query()->whereIn('id', $res)->orderBy('name')->pluck('name', 'id');
|
||||
})
|
||||
->preload()
|
||||
->searchable()
|
||||
->columnSpan(2)
|
||||
->label('League'),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
->recordActions([
|
||||
EditAction::make()->iconButton(),
|
||||
DeleteAction::make()->iconButton(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
-9
@@ -3,7 +3,6 @@
|
||||
namespace App\Filament\Clusters\StaticData\Resources\StatistikoEvents\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\StatistikoEvents\StatistikoEventsResource;
|
||||
// use App\Filament\Imports\StatistikoEventImporter;
|
||||
use App\Models\StatistikoEvent;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\CreateAction;
|
||||
@@ -27,14 +26,6 @@ class ListStatistikoEvents extends ListRecords
|
||||
CreateAction::make()
|
||||
->label('New')
|
||||
->icon('phosphor-plus'),
|
||||
// ImportAction::make('importEvents')
|
||||
// ->maxRows(200000)
|
||||
// ->color('success')
|
||||
// ->chunkSize(250)
|
||||
// ->icon('phosphor-upload')
|
||||
// ->label('Import')
|
||||
// ->modalDescription('Max 20k rows per import, column separator: ";"')
|
||||
// ->importer(StatistikoEventImporter::class),
|
||||
];
|
||||
}
|
||||
}
|
||||
-5
@@ -47,9 +47,4 @@ class StatistikoEventsResource extends Resource
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
|
||||
public static function getNavigationBadgeColor(): ?string
|
||||
{
|
||||
return 'success';
|
||||
}
|
||||
}
|
||||
-1
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\StatistikoEvents\Tables;
|
||||
|
||||
use App\Models\Sport;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
|
||||
+5
-3
@@ -20,10 +20,12 @@ class StatistikoImportForm
|
||||
->options(Sport::where('is_active', 1)->pluck('name', 'id')),
|
||||
Select::make('data_type')
|
||||
->required()
|
||||
->allowHtml()
|
||||
->options([
|
||||
'player' => 'Player',
|
||||
'events' => 'Events',
|
||||
'events_player' => 'Events & Player',
|
||||
'player' => '<span class="text-blue-500">Player</span>',
|
||||
'events' => '<span class="text-green-500">Events</span>',
|
||||
'fixtures' => '<span class="text-orange-500">Fixtures</span>',
|
||||
'events_player' => '<span class="text-pink-600">Events & Player</span>',
|
||||
]),
|
||||
|
||||
FileUpload::make('file_name')
|
||||
|
||||
+1
-1
@@ -34,11 +34,11 @@ class StatistikoImportsTable
|
||||
->options([
|
||||
'player' => '<span class="text-blue-500">Player</span>',
|
||||
'events' => '<span class="text-green-500">Events</span>',
|
||||
'fixtures' => '<span class="text-orange-500">Fixtures</span>',
|
||||
'events_player' => '<span class="text-amber-500">Events & Player</span>',
|
||||
]),
|
||||
TextColumn::make('file_name_original')
|
||||
->searchable()
|
||||
->color('primary')
|
||||
->label('Name'),
|
||||
IconColumn::make('has_run')
|
||||
->label('Import')
|
||||
|
||||
-10
@@ -3,11 +3,9 @@
|
||||
namespace App\Filament\Clusters\StaticData\Resources\StatistikoPlayers\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\StatistikoPlayers\StatistikoPlayerResource;
|
||||
// use App\Filament\Imports\StatistikoPlayerImporter;
|
||||
use App\Models\StatistikoPlayer;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\CreateAction;
|
||||
// use Filament\Actions\ImportAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListStatistikoPlayers extends ListRecords
|
||||
@@ -27,14 +25,6 @@ class ListStatistikoPlayers extends ListRecords
|
||||
CreateAction::make()
|
||||
->label('New')
|
||||
->icon('phosphor-plus'),
|
||||
// ImportAction::make('importPlayer')
|
||||
// ->maxRows(200000)
|
||||
// ->color('success')
|
||||
// ->chunkSize(250)
|
||||
// ->icon('phosphor-upload')
|
||||
// ->label('Import')
|
||||
// ->modalDescription('Max 20k rows per import, column separator ";"')
|
||||
// ->importer(StatistikoPlayerImporter::class),
|
||||
];
|
||||
}
|
||||
}
|
||||
+1
-6
@@ -24,7 +24,7 @@ class StatistikoPlayerResource extends Resource
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
protected static ?int $navigationSort = 2;
|
||||
protected static ?int $navigationSort = 4;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'giocatore';
|
||||
|
||||
@@ -49,9 +49,4 @@ class StatistikoPlayerResource extends Resource
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
|
||||
public static function getNavigationBadgeColor(): ?string
|
||||
{
|
||||
return 'success';
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user