Search
 
SCRIPT & CODE EXAMPLE
 

PHP

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

foreign key in Laravel

// one_line code for foreign in laravel
$table->foreignId('user_id')->constrained()->onDelete('cascade');
Comment

laravel foreign key constraint

public function up()
{
    Schema::create('replies', function (Blueprint $table) {
        $table->bigIncrements('id');
        $table->text('body');
        $table->unsignedBigInteger('question_id');
        $table->integer('user_id')->unsigned();
        $table->foreign('question_id')->references('id')->on('questions')->onDelete('cascade');
        $table->timestamps();
    });
}
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

laravel 8 foreign key

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

Laravel adding Foreign Key Constraints

$table->foreignId('user_id')
      ->constrained("users") <- // You don't need to specify table if it matched laravel naming conventions.
      ->onUpdate('cascade')
      ->onDelete('cascade');
Comment

laravel foreign key

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

How to create foreign key in Laravel

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

foreign key string laravel

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

PREVIOUS NEXT
Code Example
Php :: tag php 
Php :: https://ubuntu.com/tutorials/install-and-configure-wordpress#3-install-wordpress 
Php :: run cron job in seconds 
Php :: laravel validation rule 
Php :: laravel empty 
Php :: twig url 
Php :: laravel find 
Php :: wordpress add action 
Php :: laravel.log" could not be opened in append mode 
Php :: how to develop package beside laravel project 
Php :: php override built in functions 
Php :: different between two dates 
Php :: PHP Custom Time Ago Function 
Php :: WooCommerce shop loop random array function not same values after each other 
Php :: #FF0000; 
Php :: search line phpstorm mac 
Php :: php glob multiple file with different formats in directory 
Php :: Filtrer les articles WordPress mis en avant 
Php :: laravel nova create resource 
Php :: Drupal 8 / 9 entityTypeManager get multiple comments by cid 
Php :: how to include page specific css in xphp smart header 
Php :: nginx phpmyadmin subdirectory 
Php :: <?php function find total( $my_list ) { //Insert your code here } ? 
Php :: acho in php 
Php :: When you click on the search button, it is moved to the page laravel 
Php :: Find template serving current page 
Php :: Formatting an Excel Column 
Php :: php is_a 
Php :: costante php define 
Php :: how to include only post variable from another file php 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =