Answers for "drop foreign key laravel"

PHP
20

laravel foreign key

Schema::table('posts', function (Blueprint $table) {
    $table->unsignedBigInteger('user_id');

    $table->foreign('user_id')->references('id')->on('users');
});
OR
Schema::table('posts', function (Blueprint $table) {
    $table->foreignId('user_id')->constrained();
});
Posted by: Guest on December-09-2020
1

larael drop foreign key

Schema::table('posts', function (Blueprint $table) {
	$table->dropForeign(['category_id']);
});
Posted by: Guest on May-07-2021
3

laravel remove foreign key

$table->dropForeign('posts_user_id_foreign');
Posted by: Guest on April-22-2020
1

laravel drop foreign column

// Searched, laravel drop foreign column
Schema::table('users', function (Blueprint $table) {
    $table->dropColumn(['votes', 'avatar', 'location']);
});
Posted by: Guest on December-09-2020
0

laravel migration constrained

Schema::table('posts', function (Blueprint $table) {
    $table->foreignId('user_id')->constrained();
});

/* The foreignId method is an alias for unsignedBigInteger while the
 * constrained method will use conventions to determine the table and
 * column name being referenced. If your table name does not match
 * Laravel's conventions, you may specify the table name by passing it
 * as an argument to the constrained method:
*/

Schema::table('posts', function (Blueprint $table) {
    $table->foreignId('user_id')->constrained('users');
});
Posted by: Guest on December-29-2020
0

drop foreign key laravel

Schema::table('admins', function (Blueprint $table) {    $table->dropForeign('admins_post_id_foreign');    $table->dropColumn('post_id');});
Posted by: Guest on September-26-2021

Code answers related to "drop foreign key laravel"

Browse Popular Code Answers by Language