Any way to reduce memory usage for database objects in Laravel? As i know, we can use toBase() to reduce memory, but when i have relation like this:
$builder = self::select(['id','title'])->where('parent_id', '0');
$builder->with('children');
return $builder->toBase()->get();
toBase converts data into stdclass without children field (but i need that field). So, i need way to use something like toBase for memory reducing but with children preservation. Children have relationship by OneToMany. How can I do that?