<?php

namespace Database\Seeders;

use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use App\Models\Episode;
use App\Models\Podcast;
use App\Models\Artwork;
use Illuminate\Support\Str;
use Illuminate\Support\Facade\Log;

class FixLegacyEpisodeSeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        $episodes = Episode::all();
        foreach ($episodes as $episode) {
            if (is_null($episode->episode_number) || $episode->episode_number == 0) {
                $ep_num_arr = explode('_', $episode->slug);
                $episode->episode_number = $ep_num_arr[0];
            }
            if ($episode->isDirty()) {
                $episode->save();
            }
        }
    }
}
