Fluency in Laravel can take several forms. One of them is using the Fluent class hidden inside the Laravel framework. The Fluent class is a utility class provided by the Laravel framework that allows you to create and manipulate objects fluently.

This article will explore how you can use the Fluent class to create and manipulate objects in Laravel.

Not only can you create an instance of the Fluent class using the make() method, you can wrap your existing Array using the Fluent class constructor as follows: $data = [ 'id' => 1, 'name' => 'Nike Air Force 1', 'price' => 50000, // cents ]; $product = new Fluent($data); Then you can access the properties like so: echo $product->name; // or echo $product[‘name’]; #how-to-create-a-fluent-object-using-an-existing-object How to create a Fluent object using an existing Object
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners