Solution for "laravel foreign key in model"

$table->unsignedBigInteger('user_id'); $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');

foreign key in laravel migration

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(); });

laravel foreign key

$table->foreign('column_name')->references('id')->on('table_name')->onDelete('cascade');

foreign key laravel migration

$table->foreignId('post_id') ->constrained() ->onUpdate('cascade') ->onDelete('cascade');

Laravel create foreign key column in migration

// in laravel if error of missing pdomysql driver issue the command // composer require doctrine/dbal DB::connection()->getDoctrineColumn($table_name, $field_name)->getType()->getName()

laravel field types from database field type

Schema::table('portfolios', function (Blueprint $table) { $table->string('filter_alias'); $table->foreign('filter_alias')->cascadeOnDelete()->references('alias')->on('filters'); });

foreign key string laravel

Similar codes for "laravel foreign key in model"


Latest 'PHP' questions

Added before "laravel foreign key in model"