vendredi 30 octobre 2015

Laravel on sorting related model?

I know from laravel documentation that I can do eager loading like:

$records = (new Route)->with('country')->get();

But when I execute this:

    $records = (new Route)->query()->with('country')->orderBy('country.name', 'asc')->paginate();

I get this error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'country.name' in 'order clause' (SQL: select * from `routes` order by `country`.`name` asc limit 2 offset 0)

How I can sort on related model ? How can I force laravel to load joined tables?



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

Aucun commentaire:

Enregistrer un commentaire