https://www.sitepoint.com/laravel-doctrine-best-of-both-worlds/ https://stackoverflow.com/questions/30231862/laravel-eloquent-has-with-wherehas-what-do-they-mean Object Relation mapping is hard as fk, so even with Active Record or Data Mapper, ORM ... It somehow sometime eager load / relation seem not work as expected. => Try figure out why condition / filter on whereHas, hasOne()... not work. ex. hasOne(UserReview, 'shop_id', 'shop_id')->orderby('created_at', 'desc')->take(1); Try use raw query first. It is somehow / maybe SQL, relational DB knowledge wrong, not Eloquent bug. https://songmeanings.com/songs/view/57458/ https://stackoverflow.com/questions/48445480/mysql-order-by-from-subquery-lost-by-group-by https://www.quora.com/Can-I-sort-faster-if-I-convert-strings-to-numbers https://stackoverflow.com/questions/16620169/do-algorithms-sort-integers-and-strings-with-the-same-time-consistency select max(id) group by for ie. ...
Some tribes of the programmer clan.