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 Use Google Translate Multi Language In Laravel
- Casting Attribute in Laravel Eloquent Models
- Sendgrid Email Send Tutorial Laravel/PHP/cURL Example
- How to Integrate Razorpay Payment Gateway in Laravel 9 Example
- Laravel 9 QR Code Generator Basic To Advanced Tutorial Example
- How to Upload Multiple Images In Laravel 10
- How To Add Active Class To Menu Item In Laravel
- Laravel 9 Sanctum API Authentication Tutorial
- could not find driver (SQL: select count(*) as aggregate from "users" where "email" = admin@gmail.com)
- Everything know about Laravel Localization With Demo Example