php - Simulating a right join in Eloquent -


i have model person belongstomany review objects.

this working great, , can query thing successfully.

what i'd query person there isn't review associated them.

i've tried things like

person::with('reviews')->wherenull('reviews.id')->get();

and

person::wherehas('reviews', function($q)     {         $q->wherenull('id');     })->get(); 

but no success - need person objects have no review objects?

this easy normal sql, have lots of other code uses eloquent models, i'd keep using eloquent here.

try wheredoesnthave:

person::wheredoesnthave('reviews')->get(); 

from api (4.2)

add relationship count condition query.

the method illuminate/database/eloquent/builder.php (see code here):

    public function wheredoesnthave($relation, closure $callback = null)     {         return $this->doesnthave($relation, 'and', $callback);     } 

which calls:

/**  * add relationship count condition query.  *  * @param  string  $relation  * @param  string  $boolean  * @param  \closure|null  $callback  * @return \illuminate\database\eloquent\builder|static  */ public function doesnthave($relation, $boolean = 'and', closure $callback = null) {     return $this->has($relation, '<', 1, $boolean, $callback); } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -