In Laravel is it possible to select only one field and return that as a set/ array.
For example consider the model Foo which is linked to table foos which has field id, a, b, c.
Consider the following sample data:
(1, 10, 15, 20)
(1, 12, 15, 27)
(1, 17, 15, 27)
(1, 25, 16, 29)
(1, 28, 16, 40)
Now if I wanted to create a query that returns all the values of a where b is 15, I could do that like so:
Foo::select('a')->where('b', 15)->get();
However this will return an eloquent collection.
Instead how can I return instead an array like this:
[10, 12, 17]
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire