Philo Hermans contributed a fluent() helper function when working with multi-dimensional arrays. The Fluent class has been in the Laravel framework for quite a while; however, this PR introduces a helper convenience method to create a fluent object instance:

$data = [
    'user' => [
        'name' => 'Philo',
        'address' => [
            'city' => 'Amsterdam',
            'country' => 'Netherlands',
        ]
    ],
    'posts' => [
        [
            'title' => 'Post 1',
        ],
        [
            'title' => 'Post 2',
        ]
    ]
];

collect($data)->get('user');
fluent($data)->user;

collect($data)->get('user')['name'];
fluent($data)->get('user.name');

collect(collect($data)->get('posts'))->pluck('title');
fluent($data)->collect('posts')->pluck('title');

json_encode(collect($data)->get('user')['address']);
fluent($data)->scope('user.address')->toJson();
continue reading on laravel-news.com

⚠️ This post links to an external website. ⚠️