Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

pivot table in laravel 9

return new class extends Migration {
    public function up()
    {
        Schema::create('blog_category', function (Blueprint $table) {
            $table->foreignIdFor(Blog::class)->constrained()->onDelete('cascade');
            $table->foreignIdFor(Category::class)->constrained()->onDelete('cascade');
            $table->primary(['blog_id', 'category_id']);

            $table->index('blog_id');
            $table->index('category_id');
        });
    }
Source by bestofphp.com #
 
PREVIOUS NEXT
Tagged: #pivot #table #laravel
ADD COMMENT
Topic
Name
8+3 =