-
-
Notifications
You must be signed in to change notification settings - Fork 319
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What does it should be when we call toArray()
?
#107
Comments
I don't think $collect = collect([
'name' => 'wei',
'sex' => 'male',
'phone' => [15211111111, 13511111111],
'company' => ['name' => 'IBM', 'city' => 'BJ']
]);
return dd($collect->toArray()); |
It's not consistent with Laravel right now because in PHP have associative arrays, while JS don't. I think it would be weird to return an object from a method called What do you think? I'm open for a discussion |
It is my (random JS developer) opinion that the closest equivalent data structure in JS would be a nested array of Input: people = {
name: 'wei',
sex: 'male',
phone: [15211111111, 13511111111],
company: {
name: 'IBM',
city: 'BJ'
}
} Output: [
['name', 'wei'],
['sex', 'male'],
['phone', [15211111111, 13511111111]],
['company', { name: 'IBM', city: 'BJ' }]
] |
dont see the usefulness of this method, would you like to give a real use scenario of it? |
In my opinion calling it ToArray is not useful, unless you needed an array, that says pass it to method which only accepted Integer() as a parameter. |
Sorry for that I'm not familiar with Laravel, I propose this problem standing at the general position. |
Suppose there is an object collection like that
What does it should be if we call
collect(people).toArray()
?In current implementation, it will return
[ 'wei', 'male', [ 15211111111, 13511111111 ], { name: 'IBM', city: 'BJ' } ]
.Should it be
[ 'wei', 'male', [ 15211111111, 13511111111 ], [ 'IBM', 'BJ' ] ]
?The text was updated successfully, but these errors were encountered: