Answers for "laravel relation one to one"

PHP
1

laravel one to one relationship

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class User extends Model
{
    /**
     * Get the phone associated with the user.
     */
    public function phone()
    {
        return $this->hasOne(Phone::class);
    }
}
Posted by: Guest on July-24-2021

Browse Popular Code Answers by Language