<?php

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

use App\Models\PhotoBlock;

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

        PhotoBlock::all()->each(function ($photo_block) {
            $photo_block->layout = 'grid';
            $photo_block->save();
        });
    }

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