From 8f541cafc0980963252fc7c4dfc1baf1aa47e4ae Mon Sep 17 00:00:00 2001 From: "Md. Mottasin Lemon" <68915904+lmottasin@users.noreply.github.com> Date: Mon, 8 Apr 2024 08:59:00 +0000 Subject: [PATCH] feat: add fluent helper doc --- helpers.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/helpers.md b/helpers.md index 23cd72599c4..633daae7744 100644 --- a/helpers.md +++ b/helpers.md @@ -169,6 +169,7 @@ Laravel includes a variety of global "helper" PHP functions. Many of these funct [event](#method-event) [fake](#method-fake) [filled](#method-filled) +[fluent](#method-fluent) [info](#method-info) [literal](#method-literal) [logger](#method-logger) @@ -1656,6 +1657,36 @@ The `blank` function determines whether the given value is "blank": For the inverse of `blank`, see the [`filled`](#method-filled) method. + +#### `fluent()` {.collection-method} + +The `fluent` function helps to working with multi-dimension arrays: + + $data = [ + 'user' => [ + 'name' => 'Taylor Otwell', + 'address' => [ + 'city' => 'Amsterdam', + 'country' => 'Netherlands', + ] + ], + 'posts' => [ + [ + 'title' => 'Post 1', + ], + [ + 'title' => 'Post 2', + ] + ] + ]; + + fluent($data)->get('user.name'); + // Taylor Otwell + fluent($data)->collect('posts')->pluck('title'); + // ['Post 1', 'Post 2'] + fluent($data)->scope('user.address')->toJson(); + // {"city":"Amsterdam","country":"Netherlands"} + #### `broadcast()` {.collection-method}