91 lines
4.2 KiB
PHP
91 lines
4.2 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Imports\Helper;
|
|
|
|
use App\Models\StatistikoPlayer;
|
|
use Illuminate\Support\LazyCollection;
|
|
use Spatie\SimpleExcel\SimpleExcelReader;
|
|
|
|
class ImportPlayer
|
|
{
|
|
public static function run(string $filePath): void
|
|
{
|
|
SimpleExcelReader::create(storage_path('app/public/'.$filePath))
|
|
->getRows()
|
|
->chunk(1000)
|
|
->each(function (LazyCollection $chunk) {
|
|
|
|
foreach ($chunk as $row) {
|
|
|
|
$row = array_values($row);
|
|
|
|
StatistikoPlayer::where('match_id', $row[0])
|
|
->where('player_id', $row[1])
|
|
->update(
|
|
[
|
|
'playersubstitute_id' => $row[2],
|
|
'goals' => $row[3],
|
|
'assists' => $row[4],
|
|
'own_goals' => $row[5],
|
|
'shots_on_target' => $row[6],
|
|
'shots_off_target' => $row[7],
|
|
'shots_blocked' => $row[8],
|
|
'fouls' => $row[9],
|
|
'was_fouled' => $row[10],
|
|
'offsides' => $row[11],
|
|
'possessions_lost' => $row[12],
|
|
'total_tackles' => $row[13],
|
|
'touches' => $row[14],
|
|
'total_cross' => $row[15],
|
|
'cross_done' => $row[16],
|
|
'total_dribbles' => $row[17],
|
|
'dribbles_won' => $row[18],
|
|
'total_ground_duels' => $row[19],
|
|
'total_ground_duels_won' => $row[20],
|
|
'total_aerial_duels' => $row[21],
|
|
'total_duels_aerial_won' => $row[22],
|
|
'total_pass' => $row[23],
|
|
'pass' => $row[24],
|
|
'total_long_balls' => $row[25],
|
|
'long_balls' => $row[26],
|
|
'blocked_shots' => $row[27],
|
|
'clearances' => $row[28],
|
|
'dribbled_past' => $row[29],
|
|
'hit_woodwork' => $row[30],
|
|
'interceptions' => $row[31],
|
|
'key_pass' => $row[32],
|
|
'last_man_tackle' => $row[33],
|
|
'dispossessed' => $row[34],
|
|
'clearance_off_line' => $row[35],
|
|
'bcc' => $row[36],
|
|
'bcm' => $row[37],
|
|
'errors_lead_to_a_goal' => $row[38],
|
|
'errors_lead_to_a_shot' => $row[39],
|
|
'penalty_committed' => $row[40],
|
|
'penalty_miss' => $row[41],
|
|
'penalty_save' => $row[42],
|
|
'penalty_won' => $row[43],
|
|
'saves' => $row[44],
|
|
'saves_from_in_box' => $row[45],
|
|
'total_runs_out' => $row[46],
|
|
'runs_out' => $row[47],
|
|
'punches' => $row[48],
|
|
'good_high_claim' => $row[49],
|
|
'minutes_played' => $row[50],
|
|
'lineup' => $row[51],
|
|
'minute_event_during_the_match' => $row[52],
|
|
'type_event_during_the_match' => $row[53],
|
|
'description_event_during_the_match' => $row[54],
|
|
'subtype_event_during_the_match' => $row[55],
|
|
'player_position' => $row[56],
|
|
'playerrating_value' => $row[57],
|
|
'tm_player_id' => $row[58],
|
|
],
|
|
['upsert' => true],
|
|
);
|
|
|
|
}
|
|
});
|
|
}
|
|
}
|