Skip to content

Support dot keys in Arr::pluck #4

Description

@malayladu

It would be a good if Arr::pluck process the dot keys.

For example, If we want to process the slug of category from the below array, we can do using 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',
    ],
  ],
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions