Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel relation one to one

// User model
public function phone()
{
  return $this->hasOne(Phone::class);
}

// User controller
$phone = User::find(1)->phone;
Comment

one to one relationship laravel

Schema::create('phones', function (Blueprint $table) {

    $table->increments('id');

    $table->integer('user_id')->unsigned();

    $table->string('phone');

    $table->timestamps();

    

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

        ->onDelete('cascade');

});
Comment

PREVIOUS NEXT
Code Example
Php :: laravel ignition dark mode 
Php :: Drupal 9 loop term objects to retrieve term data (id, name, uuid) 
Php :: how to import csv into database in laravel 
Php :: add backslash to path wordpress 
Php :: envoyer mail php depuis localhost 
Php :: how to convert array into json php 
Php :: php json array push in js file 
Php :: laravel creating event get data 
Php :: symfony clear session 
Php :: codecept run single test 
Php :: WordPress Emojis abschalten 
Php :: how to react on a html button click in php 
Php :: php if simple 
Php :: ascii vrednosti php 
Php :: auto complete order paid1 
Php :: Number in English Words (Indian format) php 
Php :: distance between two locations in php 
Php :: laravel api get controller 
Php :: date + 14 days php 
Php :: Laravel display the date the participation was created 
Php :: php get long word in array 
Php :: tina4 create route 
Php :: cách nhúng php vào html 
Php :: php double dollar not working in php version 8 
Php :: array value auto fill in old value laravel 8 
Php :: laravel Undefined index: token on reset 
Php :: laravel dispatch execute multiple 
Php :: WPML - Add a floating language switcher to the footer 
Php :: wp ajax error handling 
Php :: Determine the percentage of the file uploaded to the server using php 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =