wip
This commit is contained in:
1 parent
f7c6b222db
commit
d08aea46cd
2 files changed
+102
-56
No files matched your search
@@ -31,40 +31,72 @@ class ImportEvents
|
|||||||
3 => 1661
|
3 => 1661
|
||||||
4 => 4781
|
4 => 4781
|
||||||
*/
|
*/
|
||||||
|
StatistikoEvent::updateOrCreate([
|
||||||
|
'match_id' => (int) $row[0],
|
||||||
|
'sport_id' => (int) $row[1],
|
||||||
|
'league_id' => (int) $row[2],
|
||||||
|
'home_id' => (int) $row[3],
|
||||||
|
'away_id' => (int) $row[4],
|
||||||
|
'starttime' => Carbon::parse($row[5])->toIso8601String(),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'season' => (int) $row[6],
|
||||||
|
'gls_h' => (int) $row[7],
|
||||||
|
'gls_a' => (int) $row[8],
|
||||||
|
'crn_h' => (int) $row[9],
|
||||||
|
'crn_a' => (int) $row[10],
|
||||||
|
'fls_h' => (int) $row[11],
|
||||||
|
'fls_a' => (int) $row[12],
|
||||||
|
'ofs_h' => (int) $row[13],
|
||||||
|
'ofs_a' => (int) $row[14],
|
||||||
|
'snt_h' => (int) $row[15],
|
||||||
|
'snt_a' => (int) $row[16],
|
||||||
|
'tsh_h' => (int) $row[17],
|
||||||
|
'tsh_a' => (int) $row[18],
|
||||||
|
'crd_h' => (int) $row[19],
|
||||||
|
'crd_a' => (int) $row[20],
|
||||||
|
'exp_home' => (float) $row[21],
|
||||||
|
'exp_away' => (float) $row[22],
|
||||||
|
'exp_handicap' => (float) $row[23],
|
||||||
|
'exp_total' => (float) $row[24],
|
||||||
|
'result_code' => $row[25], // w, d, l
|
||||||
|
'created_at' => $now,
|
||||||
|
'updated_at' => $now,
|
||||||
|
]);
|
||||||
|
|
||||||
StatistikoEvent::where('match_id', (int) $row[0])
|
// StatistikoEvent::where('match_id', (int) $row[0])
|
||||||
->where('sport_id', (int) $row[1])
|
// ->where('sport_id', (int) $row[1])
|
||||||
->where('league_id', (int) $row[2])
|
// ->where('league_id', (int) $row[2])
|
||||||
->where('home_id', (int) $row[3])
|
// ->where('home_id', (int) $row[3])
|
||||||
->where('away_id', (int) $row[4])
|
// ->where('away_id', (int) $row[4])
|
||||||
->where('starttime', Carbon::parse($row[5])->toIso8601String())
|
// ->where('starttime', Carbon::parse($row[5])->toIso8601String())
|
||||||
->update(
|
// ->update(
|
||||||
[
|
// [
|
||||||
'season' => (int) $row[6],
|
// 'season' => (int) $row[6],
|
||||||
'gls_h' => (int) $row[7],
|
// 'gls_h' => (int) $row[7],
|
||||||
'gls_a' => (int) $row[8],
|
// 'gls_a' => (int) $row[8],
|
||||||
'crn_h' => (int) $row[9],
|
// 'crn_h' => (int) $row[9],
|
||||||
'crn_a' => (int) $row[10],
|
// 'crn_a' => (int) $row[10],
|
||||||
'fls_h' => (int) $row[11],
|
// 'fls_h' => (int) $row[11],
|
||||||
'fls_a' => (int) $row[12],
|
// 'fls_a' => (int) $row[12],
|
||||||
'ofs_h' => (int) $row[13],
|
// 'ofs_h' => (int) $row[13],
|
||||||
'ofs_a' => (int) $row[14],
|
// 'ofs_a' => (int) $row[14],
|
||||||
'snt_h' => (int) $row[15],
|
// 'snt_h' => (int) $row[15],
|
||||||
'snt_a' => (int) $row[16],
|
// 'snt_a' => (int) $row[16],
|
||||||
'tsh_h' => (int) $row[17],
|
// 'tsh_h' => (int) $row[17],
|
||||||
'tsh_a' => (int) $row[18],
|
// 'tsh_a' => (int) $row[18],
|
||||||
'crd_h' => (int) $row[19],
|
// 'crd_h' => (int) $row[19],
|
||||||
'crd_a' => (int) $row[20],
|
// 'crd_a' => (int) $row[20],
|
||||||
'exp_home' => (float) $row[21],
|
// 'exp_home' => (float) $row[21],
|
||||||
'exp_away' => (float) $row[22],
|
// 'exp_away' => (float) $row[22],
|
||||||
'exp_handicap' => (float) $row[23],
|
// 'exp_handicap' => (float) $row[23],
|
||||||
'exp_total' => (float) $row[24],
|
// 'exp_total' => (float) $row[24],
|
||||||
'result_code' => $row[25], // w, d, l
|
// 'result_code' => $row[25], // w, d, l
|
||||||
'created_at' => $now,
|
// 'created_at' => $now,
|
||||||
'updated_at' => $now,
|
// 'updated_at' => $now,
|
||||||
],
|
// ],
|
||||||
['upsert' => true],
|
// ['upsert' => true],
|
||||||
);
|
// );
|
||||||
} else {
|
} else {
|
||||||
StatistikoEvent::insert(
|
StatistikoEvent::insert(
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ class ImportPlayer
|
|||||||
SimpleExcelReader::create(storage_path('app/public/'.$filePath))
|
SimpleExcelReader::create(storage_path('app/public/'.$filePath))
|
||||||
->getRows()
|
->getRows()
|
||||||
->chunk(1000)
|
->chunk(1000)
|
||||||
->each(function (LazyCollection $chunk) use ($fieldnames, $importmode) {
|
->each(function (LazyCollection $chunk) use ($fieldnames) {
|
||||||
|
|
||||||
foreach ($chunk as $row) {
|
foreach ($chunk as $row) {
|
||||||
|
|
||||||
@@ -23,29 +23,43 @@ class ImportPlayer
|
|||||||
|
|
||||||
// print_r($row);
|
// print_r($row);
|
||||||
|
|
||||||
if ($importmode == 'update') {
|
$update_array = [];
|
||||||
|
foreach ($fieldnames as $key => $name) {
|
||||||
$update_array = [];
|
$offset = (int) $key + 4;
|
||||||
foreach ($fieldnames as $key => $name) {
|
$update_array[$name] = $row[$offset];
|
||||||
$offset = (int) $key + 4;
|
|
||||||
$update_array[$name] = $row[$offset];
|
|
||||||
}
|
|
||||||
|
|
||||||
// dd($update_array);
|
|
||||||
|
|
||||||
StatistikoPlayer::where('sport_id', (int) $row[0])
|
|
||||||
->where('match_id', (int) $row[1])
|
|
||||||
->where('ss_player_id', (int) $row[2])
|
|
||||||
->where('tm_player_id', (int) $row[3])
|
|
||||||
->update($update_array, ['upsert' => true]);
|
|
||||||
} else {
|
|
||||||
$insert_array = [];
|
|
||||||
foreach ($fieldnames as $key => $name) {
|
|
||||||
$insert_array[$name] = $row[$key];
|
|
||||||
}
|
|
||||||
|
|
||||||
StatistikoPlayer::insert($insert_array);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// dd($update_array);
|
||||||
|
|
||||||
|
StatistikoPlayer::where('sport_id', (int) $row[0])
|
||||||
|
->where('match_id', (int) $row[1])
|
||||||
|
->where('ss_player_id', (int) $row[2])
|
||||||
|
->where('tm_player_id', (int) $row[3])
|
||||||
|
->update($update_array, ['upsert' => true]);
|
||||||
|
|
||||||
|
// if ($importmode == 'update') {
|
||||||
|
|
||||||
|
// $update_array = [];
|
||||||
|
// foreach ($fieldnames as $key => $name) {
|
||||||
|
// $offset = (int) $key + 4;
|
||||||
|
// $update_array[$name] = $row[$offset];
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // dd($update_array);
|
||||||
|
|
||||||
|
// StatistikoPlayer::where('sport_id', (int) $row[0])
|
||||||
|
// ->where('match_id', (int) $row[1])
|
||||||
|
// ->where('ss_player_id', (int) $row[2])
|
||||||
|
// ->where('tm_player_id', (int) $row[3])
|
||||||
|
// ->update($update_array, ['upsert' => true]);
|
||||||
|
// } else {
|
||||||
|
// $insert_array = [];
|
||||||
|
// foreach ($fieldnames as $key => $name) {
|
||||||
|
// $insert_array[$name] = $row[$key];
|
||||||
|
// }
|
||||||
|
|
||||||
|
// StatistikoPlayer::insert($insert_array);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user