1 year ago

orderBy on nested relation

Posted 1 year ago by saqueib

I am using a polymorphic relation and I want to get all the post order by comments.like_count but it's not working, I have tried following


this gives error no column like_count from DB

->with(['comment' => function($query) {

Post Model

class Post extends Model {

    public function comment()
        return $this->morphTo();


Please help

Please sign in or create an account to participate in this conversation.