Y
Y
Yurka Blokhin2018-07-20 14:09:56
Laravel
Yurka Blokhin, 2018-07-20 14:09:56

Selecting two fields at once in Laravel?

I have a table with the following structure

id
sell_user_id
buy_user_id

Please tell me how to make a request so that all data in which, for example, sell_user_id = 1 and buy_user_id = 1, are included in the selection, and if sell_user_id = buy_user_id, then two fields were created.
Now I am doing with the orWhere method
$trades = $trades->where(function($query) use ($request) {
    $query->where('trades.sell_user_id', $request->user()->id)->orWhere('trades.buy_user_id', $request->user()->id);
});

but if sell_user_id = buy_user_id, then only one field comes into the result.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question