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

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners