laravel 8 one to one relation code example
Example: laravel relation one to one
// User model
public function phone()
{
return $this->hasOne(Phone::class);
}
// User controller
$phone = User::find(1)->phone;
// User model
public function phone()
{
return $this->hasOne(Phone::class);
}
// User controller
$phone = User::find(1)->phone;