Open malayladu opened 2 weeks ago
It would be a good if Arr::pluck process the dot keys.
Arr::pluck
For example, If we want to process the slug of category from the below array, we can do using Arr::pluck($categories, 'category.slug')
slug
category
Arr::pluck($categories, 'category.slug')
[ 0 => [ 'product_id' => 7, 'category_id' => 1, 'id' => 1, 'created' => '2024-11-08 10:34:29', 'category' => [ 'name' => 'Movies', 'slug' => 'movies', 'id' => 1, 'created' => '2024-11-08 10:34:29', ], ], 1 => [ 'product_id' => 7, 'category_id' => 2, 'id' => 2, 'created' => '2024-11-08 10:34:29', 'category' => [ 'name' => 'Sports', 'slug' => 'sports', 'id' => 2, 'created' => '2024-11-08 10:34:29', ], ], 2 => [ 'product_id' => 7, 'category_id' => 3, 'id' => 3, 'created' => '2024-11-08 10:34:29', 'category' => [ 'name' => 'Politics', 'slug' => 'politics', 'id' => 3, 'created' => '2024-11-08 10:34:29', ], ], ]
Is the goal in this circumstance to return an array of category slugs from each one, in this case?
Yes, it should return slugs from each one.
$categories = [ 'movies', 'sports', 'politics', ];
It would be a good if
Arr::pluck
process the dot keys.For example, If we want to process the
slug
ofcategory
from the below array, we can do usingArr::pluck($categories, 'category.slug')