hasone relations laravel 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: how to use where relationship laravel
Event::with(["owner", "participants" => function($q) use($someId){
$q->where('participants.IdUser', '=', 1);
//$q->where('some other field', $someId);
}])