Search
 
SCRIPT & CODE EXAMPLE
 

PHP

foreignId in laravel

// for laravel 7 or above. 
$table->foreignId('user_id')->constrained();
/*-----------OR---------------*/
$table->foreignId('user_id')->constrained('users');
Comment

create foreign key laravel migration

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

    $table->foreign('user_id')->references('id')->on('users');
});
Comment

laravel 8 foreign key migration

use IlluminateDatabaseSchemaBlueprint;
use IlluminateSupportFacadesSchema;

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

    $table->foreign('user_id')->references('id')->on('users');
});
Comment

foreign key laravel migration

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

add foreign key in laravel migration

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

Laravel create foreign key column in migration

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

Laravel migrations custom foreign key

$table->unsignedBigInteger('created_by');
$table->foreign('created_by')->references('id')->on('users');
Comment

PREVIOUS NEXT
Code Example
Php :: laravel 9 route controller group 
Php :: error log array 
Php :: datetime difference in php 
Php :: There is no existing directory at "/var/www/storage/logs" and it could not be created: Permission denied 
Php :: pasar datetime a string php 
Php :: how to get browser info in php 
Php :: year shortcode 
Php :: include external php file in html 
Php :: php check if non-object 
Php :: hide wordpress errors 
Php :: init hook wordpress 
Php :: superglobal php 
Php :: carbon minus 1 day 
Php :: how get file size in laravel 
Php :: php open url 
Php :: php artisan serve specify ip 
Php :: laravel csrf-token in view 
Php :: laravel find or fail exception 
Php :: laravel session flash 2020 
Php :: laravel 8 bootstrap pagination fix 
Php :: php datetime object get unix timestamp 
Php :: php convert array to json object 
Php :: define url wordpress 
Php :: group by laravel 
Php :: wait php 
Php :: get hours difference between two dates in php 
Php :: setcookie php 
Php :: doument root phpp 
Php :: how to limit excerpt length in wordpress 
Php :: Find out how many years there are in php between years 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =