mercredi 9 novembre 2016

How to get an array of 2-tuples from Laravel query builder?

Basically, I want to do this:

$locals['companies'] = Company::orderBy('name')->get(['id','name'])->map(function($c) { return [$c->id, $c->name]; })->toArray();

But without such a verbose map function. Isn't there a get-like method that will return flat numeric arrays instead of objects?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire