Answer the question
In order to leave comments, you need to log in
When is it better to work with objects, and when with arrays, using an example?
For example, working with eloquent, I get a collection
. Then I pass this object to the template. I use Twig and it would probably be more convenient to work with an array rather than an object. Am I right in thinking that before passing data from the controller to the view, the object must be converted to an array?
And the second question. It is not converted to an array, apparently because dependencies interfere? How then to be?$products=Product::with('colors')->get();
$products=Product::with('colors')->get();
$prod = $products->toArray();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question