cyberfly
12/20/2017 - 6:48 AM

Laravel Collection get array of value from Object

$core_applications = [
    [
        'name' => 'ATEP',
        'uuid' => '5e7282dc-af1b-4ce7-a7cb-858e03a41797',
        'code' => 'ATEP'
    ],
    [
        'name' => 'APRA',
        'uuid' => '5e7282dc-af1b-4ce7-a7cb-858e03a41798',
        'code' => 'APRA'
    ],
];

$core_applications = collect($core_applications);

$core_applications_ids = $core_applications->pluck('uuid');

var_dump($core_application_ids);

/*
Eg:

object(Illuminate\Support\Collection)#724 (1) {
  ["items":protected]=>
  array(1) {
    [0]=>
    string(36) "5e7282dc-af1b-4ce7-a7cb-858e03a41797"
  }
}

*/