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.
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners