How to get a model in the form of an array, the keys of which are the values of the id column?
2 answers
If it means to get a collection from models, the keys of which are id, then rather Entites :: all () -> keyBy ('id');
|
$entity = Entity::first(); $entity->toArray();
true for result collections:
$entities = Entity::all(); $entities->toArray();
- StackOverflow does not support formatting with the help of three bektik, only with the help of indents. - Athari
|