Why can’t you dump ($result->getData()) directly after $result = Staff::select($where) instead of traversing the array foreach ($result as $value)
jesse2018-09-07 22:40:57
Let’s take an official screenshot first to confirm the correctness of my underlying source code analysis:
jesse2018-09-07 14:49:33
There are still several aspects to be discussed about this issue:
1. Since the data exists in the data attribute, how to determine the data attribute and remove the data set when traversing the object
2. This is just a Model object. If it is a Collection object, how is it implemented?
ArrayAccess should appear when these two problems arise. I will update it when I go back in the evening, so that you can truly understand the underlying operating mechanism of object traversal.
jesse2018-09-07 14:27:18
First read the official manual instructions:
Then look at the underlying source code:
Both the Model class and the Collection class implement the same ArrayAccess interface, so that they can be accessed like an array properties in the object.