Skip to content

Commit

Permalink
feat: seeder that updates the theme slug according to our new standard (
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyrch authored Dec 21, 2023
1 parent f8ed4da commit 6a2b0f3
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions database/seeders/Wiki/Anime/ThemeSlugSeeder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

namespace Database\Seeders\Wiki\Anime;

use App\Models\Wiki\Anime\AnimeTheme;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;

class ThemeSlugSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
AnimeTheme::query()->where(AnimeTheme::ATTRIBUTE_SLUG, 'OP')->update([
AnimeTheme::ATTRIBUTE_SLUG => 'OP1'
]);

AnimeTheme::query()->where(AnimeTheme::ATTRIBUTE_SLUG, 'ED')->update([
AnimeTheme::ATTRIBUTE_SLUG => 'ED1'
]);

AnimeTheme::query()->where(AnimeTheme::ATTRIBUTE_SLUG, 'LIKE', 'OP-%')->update([
AnimeTheme::ATTRIBUTE_SLUG => DB::raw('CONCAT("OP1-", SUBSTRING(slug, 4))')
]);

AnimeTheme::query()->where(AnimeTheme::ATTRIBUTE_SLUG, 'LIKE', 'ED-%')->update([
AnimeTheme::ATTRIBUTE_SLUG => DB::raw('CONCAT("ED1-", SUBSTRING(slug, 4))')
]);
}
}

0 comments on commit 6a2b0f3

Please sign in to comment.