wip mango
This commit is contained in:
1 parent
df60d37f3a
commit
ad7925bbba
19 files changed
+19040
-138
No files matched your search
@@ -17,7 +17,7 @@ class PlayersTable
|
||||
Stack::make([
|
||||
TextColumn::make('name')
|
||||
->searchable(),
|
||||
TextColumn::make('player_id')
|
||||
TextColumn::make('id')
|
||||
->badge()
|
||||
->searchable(),
|
||||
]),
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\UbEvents\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\UbEvents\UbEventResource;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateUbEvent extends CreateRecord
|
||||
{
|
||||
protected static string $resource = UbEventResource::class;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\UbEvents\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\UbEvents\UbEventResource;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditUbEvent extends EditRecord
|
||||
{
|
||||
protected static string $resource = UbEventResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
DeleteAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\UbEvents\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\UbEvents\UbEventResource;
|
||||
use App\Filament\Imports\UbEventImporter;
|
||||
use Filament\Actions\ImportAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListUbEvents extends ListRecords
|
||||
{
|
||||
protected static string $resource = UbEventResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
ImportAction::make('importPlayer')
|
||||
->icon('phosphor-upload')
|
||||
->label('Events')
|
||||
->modalDescription('Separator comma ";"')
|
||||
->importer(UbEventImporter::class),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\UbEvents\Schemas;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class UbEventForm
|
||||
{
|
||||
public static function configure(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\UbEvents\Tables;
|
||||
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class UbEventsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
// TextColumn::make('league_id')->searchable(),
|
||||
TextColumn::make('league.name')->searchable(),
|
||||
// TextColumn::make('home_id')->searchable(),
|
||||
// TextColumn::make('away_id')->searchable(),
|
||||
TextColumn::make('home.name')->searchable(),
|
||||
TextColumn::make('away.name')->searchable(),
|
||||
TextColumn::make('player.name')->searchable(),
|
||||
TextColumn::make('starttime')->dateTime('d. M. Y')->label('Date'),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\UbEvents;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\UbEvents\Pages\ListUbEvents;
|
||||
use App\Filament\Clusters\StaticData\Resources\UbEvents\Schemas\UbEventForm;
|
||||
use App\Filament\Clusters\StaticData\Resources\UbEvents\Tables\UbEventsTable;
|
||||
use App\Filament\Clusters\StaticData\StaticDataCluster;
|
||||
use App\Models\UbEvent;
|
||||
use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class UbEventResource extends Resource
|
||||
{
|
||||
protected static ?string $model = UbEvent::class;
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = 'icon-soccerball';
|
||||
|
||||
protected static ?string $navigationLabel = 'Events';
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'league_id';
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return UbEventForm::configure($schema);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return UbEventsTable::configure($table);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListUbEvents::route('/'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return parent::getEloquentQuery()->count();
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ class PlayerImporter extends Importer
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('player_id')
|
||||
ImportColumn::make('id')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
@@ -43,7 +43,7 @@ class PlayerImporter extends Importer
|
||||
public function resolveRecord(): Player
|
||||
{
|
||||
return Player::firstOrNew([
|
||||
'player_id' => (int) $this->data['player_id'],
|
||||
'id' => (int) $this->data['id'],
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,417 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\UbEvent;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Illuminate\Support\Number;
|
||||
|
||||
class UbEventImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = UbEvent::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('league_id')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('home_id')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('away_id')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('player_id')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('starttime')
|
||||
->castStateUsing(function ($state) {
|
||||
$state = Carbon::parse($state)->format('Y-m-d h:i:s');
|
||||
|
||||
return $state;
|
||||
})
|
||||
->requiredMapping(),
|
||||
ImportColumn::make('home_away')
|
||||
->castStateUsing(function (string $state): ?string {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (string) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('home_ft')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('away_ft')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('home_ht')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('away_ht')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('goals')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('assists')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('tackles')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('total_passes')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('passes_done')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('total_duels')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('duels_won')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('total_ground_duels')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('ground_duels_won')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('total_aerial_duels')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('aerial_duels_won')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('minutes_played')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('shots_on_target')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('shots_off_target')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('shots_blocked')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('total_dribble')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('dribble_done')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('position')
|
||||
->castStateUsing(function (string $state): ?string {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (string) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('rating')
|
||||
->castStateUsing(function (string $state): ?float {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (float) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('bcm')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('hw')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('pw')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('pm')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('possession_lost')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('fouls')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('was_fouled')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('offsides')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('date_acquisition')
|
||||
->castStateUsing(function ($state) {
|
||||
$state = Carbon::parse($state)->format('Y-m-d h:i:s');
|
||||
|
||||
return $state;
|
||||
})
|
||||
->requiredMapping(),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): UbEvent
|
||||
{
|
||||
return UbEvent::firstOrNew([
|
||||
'league_id' => (int) $this->data['league_id'],
|
||||
'home_id,' => (int) $this->data['home_id'],
|
||||
'player_id' => (int) $this->data['player_id'],
|
||||
'away_id,' => (int) $this->data['away_id'],
|
||||
'starttime' => Carbon::parse(strtotime($this->data['starttime'])),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your ub event import has completed and '.Number::format($import->successful_rows).' '.str('row')->plural($import->successful_rows).' imported.';
|
||||
|
||||
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||
$body .= ' '.Number::format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to import.';
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user