Answer the question
In order to leave comments, you need to log in
Laravel query with with and where?
And how could one get data when: there is an order and it has many offers, you need to get all orders with the search status and if it has offers with user_id == Auth::id() . It seems like you can’t just do it through where and with
$orders = Order::where('status', 'search')
->with([
'offers' => function ($q) {
$q->where('user_id', Auth()->id())->first();
}
])->get();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question