Migrations - rodinandrey/dev_notes GitHub Wiki

    public function up(): void
    {
        Schema::create('persons', function (Blueprint $table) {
            $table->id();
        });

        Schema::table('doctors', function (Blueprint $table) {
            $table->unsignedBigInteger('person_id')
                ->nullable()
                ->after('id');
            $table->foreign('person_id', 'person_id_foreign')
                ->references('id')
                ->on('persons')
                ->nullOnDelete();
        });
    }

    public function down(): void
    {
        Schema::table('doctors', function (Blueprint $table) {
            $table->dropForeign('person_id_foreign');
            $table->dropColumn('person_id');
        });
        Schema::dropIfExists('persons');
    }

Так как тип enum не поддерживает динамическое изменение значений, в методе можно указать array_column(StatusEnum::cases(), 'value'), который вернет массив значений перечисления. Это позволит автоматически добавлять новые значения в столбец status при добавлении новых значений в перечисление StatusEnum.

$table->enum('status', StatusEnum::cases()->enumValues())->nullable();