1// User model
2public function phone()
3{
4 return $this->hasOne(Phone::class);
5}
6
7// User controller
8$phone = User::find(1)->phone;
1<?php
2
3namespace App\Models;
4
5use Illuminate\Database\Eloquent\Model;
6
7class User extends Model
8{
9 /**
10 * Get the phone associated with the user.
11 */
12 public function phone()
13 {
14 return $this->hasOne(Phone::class);
15 }
16}