Closed davemathews closed 10 years ago
find
returns a single object, why are you calling first
on it?
I can understand that, my point was while that was not an expected use, it did not give an expected result, was not sure if it was going to lead to other issues possibly.
It should return the same result as Eloquent. You're calling find
which returns a model instance, and then you call first
which (is passed to the query builder) returns a different model instance. So it should actually ignore the first find
.
I tried using the Moloquent as below which works within eloquent to return things as expected. //Should return the given value in the column name for the given find id Model::find($id)->first()->column_name;
This works in Eloquent just as expected but in the Moloquent example it instead ignores the find($id) and just returns the first record in the database instead of the one I was looking for. //Had to change to this Model::find($id)->get()->toArray()['column_name'];
This is just an FYI that in this case nesting the methods does not return as expected from Eloquent.