Hello, Developer
Here you see that how to Pluck data from Database in laravel by pluck method this is one of the simplest method to get specific column data trough to specify the name of the column it is very simple to learn as well as find out data from database using pluck method.
Whene you using pluck method at that time put that name which you want to get column it will show output array and whenever you put the name of the column and id in pluck method you will get the name of the column with id and that id become key of that name of a column, here webappfix below give an explanation with example do according to below example and you will get output from laravel pluck method.
Pluck method is a part of laravel it will retrieving a list of data from database in specify list and value given $array.
It is mostly using while compair in_array() two array and want's to unique result that time mostly used.
So, Here I will guide you step by step how to use Pluck method in laravel.
Example 1 : Controller
App/http/controller/dashboardController
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use User;
class dashboardController extends Controller
{
$data = User::pluck('id','email');
dd($data);
}
Output
array = [
1 => abc@gmail.com,
2 => xyz@gmail.com,
3 => qwe@gmail.com
];
Without pluck id it will generate auto key.
jQuery load more data on scroll
Example 2 : Controller
App/http/controller/dashboardController
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use User;
class dashboardController extends Controller
{
$data = User::pluck('email');
dd($data);
}
array = [
0 => abc@gmail.com,
1 => xyz@gmail.com,
2 => qwe@gmail.com
];
We always thanks to you for reading our blogs.
Dharmesh Chauhan
(Swapinfoway Founder)Hello Sir, We are brothers origin from Gujarat India, Fullstack developers working together since 2016. We have lots of skills in web development in different technologies here I mention PHP, Laravel, Javascript, Vuejs, Ajax, API, Payment Gateway Integration, Database, HTML5, CSS3, and Server Administration. So you need our service Please Contact Us
Haresh Chauhan
(Co-Founder)We Are Also Recommending You :
- How To Generate Image From HTML Using Snappy In Laravel 9
- Cashfree Payment Gateway Integration In Laravel
- Laravel 12 REST API Tutorial for Beginners (Step-by-Step Guide 2026)
- How to Generate PDF in Laravel 6 Example
- Laravel 10 Restful API Passport Authentication Tutorial
- How To Restrict User Access From IP Address Laravel
- How to Get Browser Name and Version in Laravel
- Laravel 10 Horizon Integration Tutorial Example
- Laravel 12 React Authentication Tutorial (Login & Register with Sanctum 2026)
- Laravel 9 REST API with Passport Authentication Tutorial