D
D
DenKG2016-12-04 22:02:47
Laravel
DenKG, 2016-12-04 22:02:47

How to output data with where condition?

How should such code look like?

$purses = Purse::orderBy('created_at', 'desc')
              where('purse_client', Auth::id())->first()
              ->get();

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
holfza, 2016-12-04
@holfza

Probably something like this will be more beautiful:

$purses = Auth::user()->purses()->orderBy('created_at', 'desc')->get();

V
Victor, 2016-12-04
@v_decadence

first returns the first entry, get is a collection of all entries.
Accordingly, you need to use one thing, depending on the purpose.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question