Eloquent query

-1

Performing a query in eloquent, which lists the records of the table to which they are related to the records in table b, up there well.

Additionally I need you to also list the records of a that are not related in b. Any suggestions?

    
asked by Erain Moya 15.03.2017 в 15:42
source

1 answer

4

In Laravel's documentation he mentions that the class Illuminate\Database\Eloquent\Builder has a method called doesntHave that would be the opposite of has .

In your case you could make the query you need like this:

$noRelated = MoldelA::doesntHave('ModelB')->get();
    
answered by 15.03.2017 / 16:17
source