I’m trying to extract the id value from a list of associative array, this is the value of $request->post('files')
:
array:2 [
0 => array:2 [
"id" => "21"
"name" => "aviary-image-1429352137570.jpeg"
]
1 => array:2 [
"id" => "22"
"name" => "1.jpg"
]
]
I tried:
$fileList = $request->post('files');
dd($fileList->pluck('id'));
But this returns:
Expected type ‘object’. Found ‘string|array|null’
So for the moment to fix this I have created a loop which iterates over the array and get only the id.
The expected result is: [21, 22]
Is there any way to do this without loop?