How can I set the name of a foreign key in php laravel
?
Schema::table('TABLE_NAME', function (Blueprint $table) {
$table->foreign(XXX)
->references(XXX)
->on('REF_TABLE')
->onDelete('cascade');
// HOW TO ACHIEVE SOMETHING LIKE THIS?
//->name('Custom name of foreign key.')
//->comment('Custom comment for foreign key.')
});
You can specify a custom name by filling the second foreign param :
->foreign('XXX', 'my_custom_name')