Answer the question
In order to leave comments, you need to log in
How to extract data from an eloquent (laravel) model and place it in a variable as an array?
Model if I correctly understood is an object. How do I convert it to a data array of one of the fields like name. I realized that in the loop I can get the data of this field
$users = \User::where(...)->get();
foreach ($users as $user)
{
echo($user->name);echo('<br>');
}
Answer the question
In order to leave comments, you need to log in
1. It's not just an object. And what class object should you find in the dock .
2. Having found what get() returns, you can easily, like a snap of the fingers of one hand, convert the entire array, and the second hand into an array with the desired structure.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question