dimanche 27 septembre 2015

Laravel 5 use Constraint Eager Loading with NULL

I have this line of code:

$route = Route::with(array('fromStation', 'toStation', 'country', 'region', 'account', 'nodes.station'))->findOrFail($id);

I have table routes and route_nodes. In route_nodes i have column named station_id which is foreign key to table stations. It can be NULL.

When I execute line above I get exception: Call to a member function addEagerConstraints() on null

So I guess problem is that I have some NULL values for station_id in table route_nodes.

What is the solution for this? Should I load without station, and then for each node on which station is not null load station model?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1LVsEat
via IFTTT

Aucun commentaire:

Enregistrer un commentaire