statistiko events
This commit is contained in:
1 parent
c1b5adb3a4
commit
3d9239737f
29 files changed
+466
-767
No files matched your search
@@ -1,60 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\Player;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Illuminate\Support\Number;
|
||||
|
||||
class PlayerImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = Player::class;
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('id')
|
||||
->castStateUsing(function (string $state): ?int {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (int) $state;
|
||||
})
|
||||
->requiredMapping()
|
||||
->numeric(),
|
||||
ImportColumn::make('name')
|
||||
->castStateUsing(function (string $state): ?string {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$state = preg_replace('@\([^\)]*\)$@', '', $state);
|
||||
|
||||
return trim($state);
|
||||
})
|
||||
->requiredMapping()
|
||||
->rules(['required', 'max:255']),
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveRecord(): Player
|
||||
{
|
||||
return Player::firstOrNew([
|
||||
'id' => (int) $this->data['id'],
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your player 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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\StatistikoEvent;
|
||||
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 StatistikoEventImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = StatistikoEvent::class;
|
||||
|
||||
public function resolveRecord(): StatistikoEvent
|
||||
{
|
||||
$res = StatistikoEvent::query()
|
||||
->where('sport_id', $this->data['sport_id'])
|
||||
->where('league_id', $this->data['league_id'])
|
||||
->where('home_id', $this->data['home_id'])
|
||||
->where('away_id', $this->data['away_id'])
|
||||
->where('starttime', $this->data['starttime'])
|
||||
->first();
|
||||
if ($res) {
|
||||
return StatistikoEvent::find($res->id);
|
||||
} else {
|
||||
return new StatistikoEvent;
|
||||
}
|
||||
}
|
||||
|
||||
public static function getColumns(): array
|
||||
{
|
||||
return [
|
||||
ImportColumn::make('sport_id')->numeric()->guess(['SPORT']),
|
||||
ImportColumn::make('league_id')->numeric()->guess(['LEAGUE']),
|
||||
ImportColumn::make('home_id')->numeric()->guess(['HOME']),
|
||||
ImportColumn::make('away_id')->numeric()->guess(['AWAY']),
|
||||
ImportColumn::make('starttime')
|
||||
->guess(['STARTTIME'])
|
||||
->castStateUsing(function ($state) {
|
||||
return Carbon::parse($state);
|
||||
}),
|
||||
ImportColumn::make('season')->guess(['SEASON']),
|
||||
ImportColumn::make('gls_h')->numeric(),
|
||||
ImportColumn::make('gls_a')->numeric(),
|
||||
ImportColumn::make('crn_h')->numeric(),
|
||||
ImportColumn::make('fls_h')->numeric(),
|
||||
ImportColumn::make('ofs_h')->numeric(),
|
||||
ImportColumn::make('snt_h')->numeric(),
|
||||
ImportColumn::make('tsh_h')->numeric(),
|
||||
ImportColumn::make('crd_h')->numeric(),
|
||||
ImportColumn::make('crn_a')->numeric(),
|
||||
ImportColumn::make('fls_a')->numeric(),
|
||||
ImportColumn::make('ofs_a')->numeric(),
|
||||
ImportColumn::make('snt_a')->numeric(),
|
||||
ImportColumn::make('tsh_a')->numeric(),
|
||||
ImportColumn::make('crd_a')->numeric(),
|
||||
ImportColumn::make('expgoalshome_value')
|
||||
->castStateUsing(function (string $state) {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (float) str_replace(',', '.', $state);
|
||||
}),
|
||||
ImportColumn::make('expgoalsaway_value')
|
||||
->castStateUsing(function (string $state) {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return str_replace(',', '.', $state);
|
||||
}),
|
||||
ImportColumn::make('exp_handicap')
|
||||
->castStateUsing(function (string $state) {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return str_replace(',', '.', $state);
|
||||
}),
|
||||
ImportColumn::make('exp_total')
|
||||
->castStateUsing(function (string $state) {
|
||||
if (blank($state)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return str_replace(',', '.', $state);
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your events 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;
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -2,31 +2,31 @@
|
||||
|
||||
namespace App\Filament\Imports;
|
||||
|
||||
use App\Models\UbPlayer;
|
||||
use App\Models\StatistikoPlayer;
|
||||
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 UbPlayerImporter extends Importer
|
||||
class StatistikoPlayerImporter extends Importer
|
||||
{
|
||||
protected static ?string $model = UbPlayer::class;
|
||||
protected static ?string $model = StatistikoPlayer::class;
|
||||
|
||||
public static function useDatabaseTransactions(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function resolveRecord(): UbPlayer
|
||||
public function resolveRecord(): StatistikoPlayer
|
||||
{
|
||||
$res = UbPlayer::query()
|
||||
$res = StatistikoPlayer::query()
|
||||
->where('id_giocatore', $this->data['id_giocatore'])
|
||||
->first();
|
||||
if ($res) {
|
||||
return UbPlayer::find($res->id);
|
||||
return StatistikoPlayer::find($res->id);
|
||||
} else {
|
||||
return new UbPlayer;
|
||||
return new StatistikoPlayer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
<?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 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')->numeric(),
|
||||
ImportColumn::make('home_id')->numeric(),
|
||||
ImportColumn::make('away_id')->numeric(),
|
||||
ImportColumn::make('player_id')->numeric(),
|
||||
ImportColumn::make('starttime')
|
||||
->castStateUsing(function ($state) {
|
||||
return Carbon::parse($state);
|
||||
}),
|
||||
ImportColumn::make('home_away')
|
||||
->castStateUsing(function (string $state): ?string {
|
||||
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 {
|
||||
return (string) trim($state);
|
||||
}),
|
||||
ImportColumn::make('rating')
|
||||
->castStateUsing(function (string $state): ?string {
|
||||
return (string) trim($state);
|
||||
}),
|
||||
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) {
|
||||
return Carbon::parse($state);
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
{
|
||||
$body = 'Your events 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