<?php

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

use App\Models\EmbedVideo;

return new class () extends Migration {
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('embed_videos', function (Blueprint $table) {
            $table->boolean('show_text')->default(false);
            $table->string('text_style')->nullable();
        });

        foreach (EmbedVideo::all() as $embed_video) {
            if ($embed_video->header || strip_tags($embed_video->body)) {
                $embed_video->show_text = true;
                $embed_video->save();
            }
        }
    }

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