Answers for "laravel pluck example"

3

pluck array in laravel

$users = User::all()->pluck('field_name');
//for keys instead of [User::all()->pluck('id');] use
$user_ids = User::all()->modelKeys();
Posted by: Guest on February-12-2021
0

laravel array_pluck

$array = [
    ['developer' => ['id' => 1, 'name' => 'Taylor']],
    ['developer' => ['id' => 2, 'name' => 'Abigail']],
];

$array = array_pluck($array, 'developer.name');

// ['Taylor', 'Abigail'];
Posted by: Guest on March-18-2021
0

laravel pluck example

DB::table('users')->where('id', 1)->pluck('name')->first();
Posted by: Guest on June-29-2021
0

laravel array_pluck

$array = array_pluck($array, 'developer.name', 'developer.id');

// [1 => 'Taylor', 2 => 'Abigail'];
Posted by: Guest on March-18-2021

Browse Popular Code Answers by Language