phplaraveleloquentlaravel-filament

Filament doesn't default value of slug


<?php
use Illuminate \Database \Migrations \Migration;
use Illuminate \Database \Schema\Blueprint;
use Illuminate de\Support\Facades\Schema;

return new class extends Migration
{

    public function up(): void
    {
        Schema::create('posts', function (Blueprint $table) {
            $table->id();
            $table->foreignId('category_id')->constrained()->onDelete('cascade
            Stable->string(title');
            $table->string('slug')->unique();
            $table->text('content');
            $table->boolean('is_published')->default(false);
            Stable->timestamps();
        });
    }

    public function down() : void
    {
        Schema::dropIfExists('posts');
    }
};

error

I has been run migration but still same error, someone can help ?

I got try to php artisan migrate:fresh and run again still having same issue.


Solution

  • You didn't pass a value for category_id. You always have to pass the value of category_id Or you can make the column nullable.

    $table->foreignId('category_id')->nullable()->constrained();