Search
 
SCRIPT & CODE EXAMPLE
 

PHP

add field to many to many relationship laravel

//in Model
public function products()
{
    return $this->belongsToMany(Product::class)
        ->withPivot('status')
        ->withTimestamps();
}
//in Migration
Schema::create('vendor_product', function (Blueprint $table) {
    $table->unsignedBigInteger('product_id');
    $table->foreign('product_id', 'product_id_fk_6766249')->references('id')->on('products')->onDelete('cascade');
    $table->unsignedBigInteger('vendor_id');
    $table->foreign('vendor_id', 'vendor_id_fk_6766249')->references('id')->on('vendors')->onDelete('cascade');
    $table->string('status');
    $table->timestamps();
});
Comment

PREVIOUS NEXT
Code Example
Php :: php post 
Php :: format datetime ISO php 
Php :: php get array key by value multidimensional 
Php :: laravel check if field has changed 
Php :: how to retrieve value from stdclass array in php 
Php :: where laravel function 
Php :: laravel migration with primary key 
Php :: wp get post author link 
Php :: php trim string to length 
Php :: wherein laravel 
Php :: wordpress get field 
Php :: How to install a specific version of package using Composer? 
Php :: php connect to data base 
Php :: how to use multiple where condition in codeigniter 
Php :: wp+get custom field phpto 
Php :: nl2br php 
Php :: phpmailer send attachment 
Php :: php utf8_decode 
Php :: sustituir caracteres especiales php 
Php :: round numnero php 
Php :: a facade root has not been set phpunit 
Php :: eloquent get distinct 
Php :: laravel order by relationship 
Php :: check type in php 
Php :: laravel get subdomain 
Php :: php exercises and solutions 
Php :: array_key_exists vs in_array 
Php :: How to create a controller in laravel 
Php :: wordpress set image quality 
Php :: if condition inside echo in php 
ADD CONTENT
Topic
Content
Source link
Name
2+6 =