php pluck code example
Example 1: pluck laravel
$name = DB::table('users')->where('name', 'John')->pluck('name');
Example 2: laravel pluck
$users = Users::pluck('name','email');
dd($users);
Example 3: laravel array_pluck
$array = [
['developer' => ['id' => 1, 'name' => 'Taylor']],
['developer' => ['id' => 2, 'name' => 'Abigail']],
];
$array = array_pluck($array, 'developer.name');
// ['Taylor', 'Abigail'];
Example 4: laravel array_pluck
$array = array_pluck($array, 'developer.name', 'developer.id');
// [1 => 'Taylor', 2 => 'Abigail'];