Search
 
SCRIPT & CODE EXAMPLE
 

PHP

make a forign key in migrations using laravel 8

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

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

add foreign key column laravel 5.8

update your `integer('user_id')` to `bigInteger('user_id')`
public function up() { 
        Schema::create('evaluation', function (Blueprint $table) { 
            $table->increments('id'); 
            $table->bigInteger('user_id')->unsigned()->index(); 
            $table->timestamps();
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
        });
    }
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

laravel foreign key

//acording to laravel 7>=

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

//for deffirent table
$table->foreignId('user_id')->constrained('users');

//for taking action
$table->foreignId('user_id')
      ->constrained()
      ->onUpdate('cascade')
      ->onDelete('cascade');
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 8 foreign key

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

laravel foreign key

$table->foreignId('user_id')
      ->constrained()
      ->onUpdate('cascade')
      ->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

How to create foreign key in Laravel

$table->foreign('category_id')->references('id')->on('categories')->onUpdate('cascade')->onDelete('cascade');
Comment

PREVIOUS NEXT
Code Example
Php :: php loop through object 
Php :: wordpress translate specific text php 
Php :: no privileges to create databases phpmyadmin 
Php :: call php from html 
Php :: PHP File Read Modes 
Php :: enque scripts from plugin 
Php :: how to print in php 
Php :: sending data from one website to another in php 
Php :: laravel auth user in constructor 
Php :: store emoji in php 
Php :: hasone relation in laravel 
Php :: php button to another page 
Php :: javascript date to php date 
Php :: set session in laravel 
Php :: what is the hashmap like in php 
Php :: mysqli_real_connect(): (HY000/2002): No such file or directory 
Php :: custom 404 page in laravel 
Php :: laravel make auth 
Php :: return view in laravel controller 
Php :: lodash tester 
Php :: maintaining serial number in laravel pagination table 
Php :: php binary to base64 
Php :: select sum laravel 
Php :: laravel observer events 
Php :: php date function get previous month 
Php :: report simple error in php 
Php :: get if bowser supports webp php 
Php :: wp post featured image not showing admin 
Php :: Merge Two Array ( Laravel ) 
Php :: php date set utc 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =