after filtering a plucked laravel collection, the indexed array change to Associative array - development

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_idfrom 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

Comments

Popular posts from this blog

ng-show doesn’t work correct with value boolean

ng-include of inline SVG does not display gradient except in Chrome

Using PHP and MySQL data to generate PDF letters like in MS Word mailmerge functionality - development