wip
This commit is contained in:
1 parent
550ea115f1
commit
c036814366
12 files changed
+481
-18891
No files matched your search
@@ -15,8 +15,12 @@ class ListPlayers extends ListRecords
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
CreateAction::make(),
|
||||
CreateAction::make()
|
||||
->label('New')
|
||||
->icon('phosphor-plus'),
|
||||
ImportAction::make('importPlayer')
|
||||
->icon('phosphor-upload')
|
||||
->label('Import')
|
||||
->modalDescription('Separator comma ",", First line: "name,player_id"')
|
||||
->importer(PlayerImporter::class),
|
||||
];
|
||||
|
||||
@@ -4,7 +4,9 @@ namespace App\Filament\Clusters\StaticData\Resources\UbEvents\Pages;
|
||||
|
||||
use App\Filament\Clusters\StaticData\Resources\UbEvents\UbEventResource;
|
||||
use App\Filament\Imports\UbEventImporter;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ImportAction;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListUbEvents extends ListRecords
|
||||
@@ -16,9 +18,26 @@ class ListUbEvents extends ListRecords
|
||||
return [
|
||||
ImportAction::make('importPlayer')
|
||||
->icon('phosphor-upload')
|
||||
->label('Events')
|
||||
->modalDescription('Separator comma ";"')
|
||||
->importer(UbEventImporter::class),
|
||||
->label('Import')
|
||||
->modalIcon('phosphor-file-csv')
|
||||
->modalDescription('Separator ";"')
|
||||
->modalHeading('Import events with player')
|
||||
->importer(UbEventImporter::class)
|
||||
->csvDelimiter(';')
|
||||
->extraModalFooterActions([
|
||||
Action::make('copy')
|
||||
->tooltip('Copy header line')
|
||||
->color('success')
|
||||
->label('Copy csv header')
|
||||
->action(function ($livewire) {
|
||||
$livewire->js('window.navigator.clipboard.writeText("league_id;home_id;away_id;starttime;player_id;home_away;home_ft;away_ft;home_ht;away_ht;Goals;assists;tackles;total_passes;passes_done;total_duels;duels_won;total_ground_duels;ground_duels_won;total_aerial_duels;aerial_duels_won;minutes_played;shots_on_target;shots_off_target;shots_blocked;total_dribble;dribble_done;position;rating;bcm;hw;pw;pm;possession_lost;fouls;was_fouled;offsides;date_acquisition");');
|
||||
|
||||
Notification::make()
|
||||
->title('Header copied successfully')
|
||||
->success()
|
||||
->send();
|
||||
}),
|
||||
]),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
namespace App\Filament\Clusters\StaticData\Resources\UbEvents\Schemas;
|
||||
|
||||
use Filament\Forms\Components\Radio;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
|
||||
class UbEventForm
|
||||
@@ -10,7 +14,81 @@ class UbEventForm
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
//
|
||||
]);
|
||||
Section::make('Player Team')
|
||||
->schema([
|
||||
Radio::make('home_away')
|
||||
->hiddenLabel()
|
||||
->options([
|
||||
'H' => 'Home',
|
||||
'A' => 'Away',
|
||||
]),
|
||||
TextInput::make('rating')
|
||||
->numeric()
|
||||
->inputMode('decimal'),
|
||||
])->columns(2),
|
||||
Grid::make([
|
||||
'default' => 2,
|
||||
'md' => 3,
|
||||
'xl' => 5,
|
||||
])
|
||||
->schema([
|
||||
TextInput::make('home_ft'),
|
||||
TextInput::make('away_ft'),
|
||||
TextInput::make('home_ht'),
|
||||
TextInput::make('away_ht'),
|
||||
TextInput::make('goals'),
|
||||
TextInput::make('assists'),
|
||||
TextInput::make('tackles'),
|
||||
TextInput::make('total_passes'),
|
||||
TextInput::make('passes_done'),
|
||||
TextInput::make('total_duels'),
|
||||
TextInput::make('duels_won'),
|
||||
TextInput::make('total_ground_duels'),
|
||||
TextInput::make('ground_duels_won'),
|
||||
TextInput::make('total_aerial_duels'),
|
||||
TextInput::make('aerial_duels_won'),
|
||||
TextInput::make('minutes_played'),
|
||||
TextInput::make('shots_on_target'),
|
||||
TextInput::make('shots_off_target'),
|
||||
TextInput::make('shots_blocked'),
|
||||
TextInput::make('total_dribble'),
|
||||
TextInput::make('dribble_done'),
|
||||
TextInput::make('position'),
|
||||
TextInput::make('bcm'),
|
||||
TextInput::make('hw'),
|
||||
TextInput::make('pw'),
|
||||
TextInput::make('pm'),
|
||||
TextInput::make('possession_lost'),
|
||||
TextInput::make('fouls'),
|
||||
TextInput::make('was_fouled'),
|
||||
TextInput::make('offsides'),
|
||||
]),
|
||||
|
||||
])->columns(1);
|
||||
}
|
||||
}
|
||||
// 'total_passes',
|
||||
// 'passes_done',
|
||||
// 'total_duels',
|
||||
// 'duels_won',
|
||||
// 'total_ground_duels',
|
||||
// 'ground_duels_won',
|
||||
// 'total_aerial_duels',
|
||||
// 'aerial_duels_won',
|
||||
// 'minutes_played',
|
||||
// 'shots_on_target',
|
||||
// 'shots_off_target',
|
||||
// 'shots_blocked',
|
||||
// 'total_dribble',
|
||||
// 'dribble_done',
|
||||
// 'position',
|
||||
// 'rating',
|
||||
// 'bcm',
|
||||
// 'hw',
|
||||
// 'pw',
|
||||
// 'pm',
|
||||
// 'possession_lost',
|
||||
// 'fouls',
|
||||
// 'was_fouled',
|
||||
// 'offsides',
|
||||
// 'date_acquisition',
|
||||
@@ -5,27 +5,65 @@ namespace App\Filament\Clusters\StaticData\Resources\UbEvents\Tables;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Forms\Components\DatePicker;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Enums\FiltersLayout;
|
||||
use Filament\Tables\Filters\Filter;
|
||||
use Filament\Tables\Filters\Indicator;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Carbon;
|
||||
|
||||
class UbEventsTable
|
||||
{
|
||||
public static function configure(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->poll('10sec')
|
||||
->columns([
|
||||
// TextColumn::make('league_id')->searchable(),
|
||||
TextColumn::make('starttime')->dateTime('d. M. Y')->label('Date'),
|
||||
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_id')->searchable(),
|
||||
TextColumn::make('player.name')->searchable(),
|
||||
TextColumn::make('starttime')->dateTime('d. M. Y')->label('Date'),
|
||||
TextColumn::make('rating'),
|
||||
])
|
||||
->filters([
|
||||
//
|
||||
])
|
||||
Filter::make('created_at')
|
||||
->columns(2)->columnSpanFull()
|
||||
->schema([
|
||||
DatePicker::make('from'),
|
||||
DatePicker::make('until'),
|
||||
])
|
||||
->query(function (Builder $query, array $data): Builder {
|
||||
return $query
|
||||
->when(
|
||||
$data['from'],
|
||||
fn (Builder $query, $date): Builder => $query->whereDate('starttime', '>=', $date),
|
||||
)
|
||||
->when(
|
||||
$data['until'],
|
||||
fn (Builder $query, $date): Builder => $query->whereDate('starttime', '<=', $date),
|
||||
);
|
||||
})
|
||||
->indicateUsing(function (array $data): array {
|
||||
$indicators = [];
|
||||
|
||||
if ($data['from'] ?? null) {
|
||||
$indicators[] = Indicator::make('Starttime from '.Carbon::parse($data['from'])->toFormattedDateString())
|
||||
->removeField('from');
|
||||
}
|
||||
|
||||
if ($data['until'] ?? null) {
|
||||
$indicators[] = Indicator::make('Starttime until '.Carbon::parse($data['until'])->toFormattedDateString())
|
||||
->removeField('until');
|
||||
}
|
||||
|
||||
return $indicators;
|
||||
}),
|
||||
], layout: FiltersLayout::AboveContent)
|
||||
->deferFilters(false)
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
|
||||
@@ -11,6 +11,7 @@ use BackedEnum;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
class UbEventResource extends Resource
|
||||
{
|
||||
@@ -18,11 +19,16 @@ class UbEventResource extends Resource
|
||||
|
||||
protected static string|BackedEnum|null $navigationIcon = 'icon-soccerball';
|
||||
|
||||
protected static ?string $navigationLabel = 'Events';
|
||||
protected static ?string $navigationLabel = 'Events & Player';
|
||||
|
||||
protected static ?string $cluster = StaticDataCluster::class;
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'league_id';
|
||||
// protected static ?string $recordTitleAttribute = 'league_id';
|
||||
|
||||
public static function getRecordTitle($record): string|null|Htmlable
|
||||
{
|
||||
return ': '.$record->starttime->format('d. M. Y').' - '.$record->league->name.' - '.$record->home->name.' vs '.$record->away->name.' - '.$record->player->name;
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
|
||||
@@ -13,397 +13,82 @@ class UbEventImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = UbEvent::class;
|
||||
|
||||
public function resolveRecord(): UbEvent
|
||||
{
|
||||
$res = UbEvent::query()
|
||||
->where('league_id', $this->data['league_id'])
|
||||
->where('home_id', $this->data['home_id'])
|
||||
->where('away_id', $this->data['away_id'])
|
||||
->where('player_id', $this->data['player_id'])
|
||||
->where('starttime', $this->data['starttime'])
|
||||
->first();
|
||||
if ($res) {
|
||||
return UbEvent::find($res->id);
|
||||
} else {
|
||||
return new UbEvent;
|
||||
}
|
||||
}
|
||||
|
||||
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('league_id')->numeric(),
|
||||
ImportColumn::make('home_id')->numeric(),
|
||||
ImportColumn::make('away_id')->numeric(),
|
||||
ImportColumn::make('player_id')->numeric(),
|
||||
ImportColumn::make('starttime')
|
||||
->castStateUsing(function ($state) {
|
||||
$state = Carbon::parse($state)->format('Y-m-d h:i:s');
|
||||
|
||||
return $state;
|
||||
})
|
||||
->requiredMapping(),
|
||||
return Carbon::parse($state);
|
||||
}),
|
||||
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(),
|
||||
return (string) trim($state);
|
||||
}),
|
||||
ImportColumn::make('home_ft')->numeric(),
|
||||
ImportColumn::make('away_ft')->numeric(),
|
||||
ImportColumn::make('home_ht')->numeric(),
|
||||
ImportColumn::make('away_ht')->numeric(),
|
||||
ImportColumn::make('goals')->numeric(),
|
||||
ImportColumn::make('assists')->numeric(),
|
||||
ImportColumn::make('tackles')->numeric(),
|
||||
ImportColumn::make('total_passes')->numeric(),
|
||||
ImportColumn::make('passes_done')->numeric(),
|
||||
ImportColumn::make('total_duels')->numeric(),
|
||||
ImportColumn::make('duels_won')->numeric(),
|
||||
ImportColumn::make('total_ground_duels')->numeric(),
|
||||
ImportColumn::make('ground_duels_won')->numeric(),
|
||||
ImportColumn::make('total_aerial_duels')->numeric(),
|
||||
ImportColumn::make('aerial_duels_won')->numeric(),
|
||||
ImportColumn::make('minutes_played')->numeric(),
|
||||
ImportColumn::make('shots_on_target')->numeric(),
|
||||
ImportColumn::make('shots_off_target')->numeric(),
|
||||
ImportColumn::make('shots_blocked')->numeric(),
|
||||
ImportColumn::make('total_dribble')->numeric(),
|
||||
ImportColumn::make('dribble_done')->numeric(),
|
||||
ImportColumn::make('position')
|
||||
->castStateUsing(function (string $state): ?string {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (string) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
return (string) trim($state);
|
||||
}),
|
||||
ImportColumn::make('rating')
|
||||
->numeric(10)
|
||||
->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(),
|
||||
return (float) str_replace(',', '.', $state) * 1.0;
|
||||
}),
|
||||
ImportColumn::make('bcm')->numeric(),
|
||||
ImportColumn::make('hw')->numeric(),
|
||||
ImportColumn::make('pw')->numeric(),
|
||||
ImportColumn::make('pm')->numeric(),
|
||||
ImportColumn::make('possession_lost')->numeric(),
|
||||
ImportColumn::make('fouls')->numeric(),
|
||||
ImportColumn::make('was_fouled')->numeric(),
|
||||
ImportColumn::make('offsides')->numeric(),
|
||||
ImportColumn::make('date_acquisition')
|
||||
->castStateUsing(function ($state) {
|
||||
$state = Carbon::parse($state)->format('Y-m-d h:i:s');
|
||||
|
||||
return $state;
|
||||
})
|
||||
->requiredMapping(),
|
||||
return Carbon::parse($state);
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
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.';
|
||||
|
||||
+39
-3
@@ -11,7 +11,7 @@ class UbEvent extends Model
|
||||
{
|
||||
protected $connection = 'mongodb';
|
||||
|
||||
protected $table = 'up_events';
|
||||
protected $table = 'events';
|
||||
|
||||
protected $fillable = [
|
||||
'league_id',
|
||||
@@ -57,8 +57,44 @@ class UbEvent extends Model
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'starttime' => 'datetime',
|
||||
'date_acquisition' => 'datetime',
|
||||
'league_id' => 'integer',
|
||||
'home_id' => 'integer',
|
||||
'away_id' => 'integer',
|
||||
'player_id' => 'integer',
|
||||
'starttime' => 'date',
|
||||
'date_acquisition' => 'date',
|
||||
'rating' => 'decimal:10',
|
||||
'home_away' => 'string',
|
||||
'home_ft' => 'integer',
|
||||
'away_ft' => 'integer',
|
||||
'home_ht' => 'integer',
|
||||
'away_ht' => 'integer',
|
||||
'goals' => 'integer',
|
||||
'assists' => 'integer',
|
||||
'tackles' => 'integer',
|
||||
'total_passes' => 'integer',
|
||||
'passes_done' => 'integer',
|
||||
'total_duels' => 'integer',
|
||||
'duels_won' => 'integer',
|
||||
'total_ground_duels' => 'integer',
|
||||
'ground_duels_won' => 'integer',
|
||||
'total_aerial_duels' => 'integer',
|
||||
'aerial_duels_won' => 'integer',
|
||||
'minutes_played' => 'integer',
|
||||
'shots_on_target' => 'integer',
|
||||
'shots_off_target' => 'integer',
|
||||
'shots_blocked' => 'integer',
|
||||
'total_dribble' => 'integer',
|
||||
'dribble_done' => 'integer',
|
||||
'position' => 'integer',
|
||||
'bcm' => 'integer',
|
||||
'hw' => 'integer',
|
||||
'pw' => 'integer',
|
||||
'pm' => 'integer',
|
||||
'possession_lost' => 'integer',
|
||||
'fouls' => 'integer',
|
||||
'was_fouled' => 'integer',
|
||||
'offsides' => 'integer',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user