Many to many boilerplate for a Laravel migration
MigrationsLaravel's Artisan command doesn't have a super simply way of creating stock many to many migrations.
Here we present our latest our latest template for your viewing pleasure:
public function up(): void
{
Schema::table('company_symbol', function (Blueprint $table) {
$table->unsignedBigInteger('company_id');
$table->unsignedBigInteger('symbol_id');
$table->foreignId('company_id')
->constrained()
->onUpdate('cascade')
->onDelete('cascade');
$table->foreignId('symbol_id')
->constrained()
->onUpdate('cascade')
->onDelete('cascade');
});
}
lang-php