laravel relation has one manager code example
Example 1: laravel hasOne
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
/**
* Get the phone record associated with the user.
*/
public function phone()
{
return $this->hasOne('App\Phone');
}
}
Example 2: eloquent relationships
$roles = App\User::find(1)->roles()->orderBy('name')->get();