<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

use App\Models\ContentElement;
use App\Models\Photo;
use App\Models\Slideshow;

return new class () extends Migration {
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        $content_elements = ContentElement::withTrashed()->where('content_type', 'App\\Models\\BannerPhoto')->get();
        $content_elements->each(function ($content_element) {
            $content_element->content_type = 'App\\Models\\Slideshow';
            $content_element->save();
        });

        $photos = Photo::withTrashed()->where('content_type', 'App\\Models\\BannerPhoto')->get();
        $photos->each(function ($photo) {
            $photo->content_type = 'App\\Models\\Slideshow';
            $photo->save();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('photos', function (Blueprint $table) {
            //
        });
    }
};
