laravel order items inside eloquent relationship

Published

So I have a query:

$order = Orders::with('comments')
            ->where(function ($query) {
                $query->where('data_checked',0);
            })->where(function ($query) {
                $query->where('status', 'new')
                    ->orWhere('status', 'confirmed')
                    ->orWhere('status', 'dispatch');
            })
            ->first();

each comment has created_at and I am trying to order comments by created_at. How can I achieve something like that?

Source: Laravel

Published
Categorised as laravel, laravel-8 Tagged ,

Answers

Leave a Reply

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq