PHP code example of josezenem / laravel-make-migration-pivot
1. Go to this page and download the library: Download josezenem/laravel-make-migration-pivot library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
josezenem / laravel-make-migration-pivot example snippets
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');
});
}
bash
php artisan make:pivot Category Blog
bash
php artisan make:pivot Category Blog
bash
php artisan vendor:publish --tag="laravel-make-migration-pivot-stubs"