DEV Community

Rohit Urane
Rohit Urane

Posted on

1

How To manage collection data in laravel?

How To manage collection data in laravel
The Collection class provides a convenient wrapper for working on an array of data. we are to manage collection in laravel. Below is an example of a collect helper which creates a new collection of instances, processes upper case on the element, and removes the nullable element.

$collection = collect(['taylor', 'abigail', null])->map(function ($name) {
    return strtoupper($name);
})
->reject(function ($name) {
    return empty($name);
});
Enter fullscreen mode Exit fullscreen mode

Creating Collection-

The collect helper returns a new collection instance for the given array. Every Eloquent query returns collection instances. Afterward, we will manage collection data in laravel.

$collection = collect([1,2,4]);
Enter fullscreen mode Exit fullscreen mode

Read More

Top comments (1)

Collapse
 
coderlegi0n profile image
CoderLegion

Perfect post

The Most Contextual AI Development Assistant

Pieces.app image

Our centralized storage agent works on-device, unifying various developer tools to proactively capture and enrich useful materials, streamline collaboration, and solve complex problems through a contextual understanding of your unique workflow.

👥 Ideal for solo developers, teams, and cross-company projects

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay