feat: champion skin data seeder

This commit is contained in:
Rico van Zelst
2023-10-31 10:20:33 +01:00
parent dc4617c576
commit ea879a8c70
5 changed files with 111 additions and 2 deletions

View File

@@ -4,6 +4,7 @@ namespace Database\Seeders;
use Illuminate\Database\Seeder;
use App\Models\Champion;
use Illuminate\Support\Facades\Log;
class ChampionSeeder extends Seeder
{
@@ -38,8 +39,10 @@ class ChampionSeeder extends Seeder
// Check if the champion already exists and if any attributes have changed, if so update the champion. If the champion doesn't exist, create it.
// This is to prevent the champion data from being updated every time the seeder is run. As I'll probably run this on a cron job.
if ($championExists && $this->hasAttributesChanged($championExists, $championAttributes)) {
Log::info('Champion ' . $champion['name'] . ' has changed, updating...');
$championExists->update($championAttributes);
} elseif (!$championExists) {
Log::info('New champion detected! Creating ' . $champion['name'] . '...');
Champion::create($championAttributes);
}
}