after filtering a plucked laravel collection, the indexed array change to Associative array
I have a collection of model eloquent such as user
model, i use the pluck
method to get the only post_id
from this collection, this method give me the indexed array of post_id
, but when i use filter or unique
method for this indexed array
the result change to Associative array
. i don’t want a assoc array
in result. I want just the unique of post_id’s in the indexed array
. laravel auto changing my result.
$this->posts->pluck('post_id')->unique('post_id')
result is :{ "1": 1 , "2": 2 }
.
Is this can a bug or I have a mistake in fetching data by methods?
from Laravel Questions and Answers https://laravelquestions.com/laravel/after-filtering-a-plucked-laravel-collection-the-indexed-array-change-to-associative-array/
via Lzo Media
No comments:
Post a Comment