Originally posted @ https://codeanddeploy.com visit and download the sample code: https://codeanddeploy.com/blog/laravel/laravel-8-eloquent-pluck-example In this post, we are using a posts table with title, description, and body fields.
And the result is the same: Array ( => Post 3 => Post 1 => Post 2 => Post 3 => Post 4 )
See the below example: $posts = Post::all()->pluck('title')->toArray(); print_r($posts);die; And the result is the same above: Array ( => Post 3 => Post 1 => Post 2 => Post 3 => Post 4 )
Kindly visit here https://codeanddeploy.com/blog/laravel/laravel-8-eloquent-pluck-example if you want to download this code.