DEV Community

Discussion on: How to Optimize Database Queries in Laravel?

 
readymadecode profile image
Chetan Rohilla

Try this

$posts = Post::all()->map(function ($post) use($custom_value) {
// modify eloquent object here
$post->custom_column = $custom_value;
//apply any condition if available
return $post;
});