We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Philo Hermans contributed a
fluent()
helper function when working with multi-dimensional arrays. TheFluent
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. ⚠️
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.