jgravois's avatar

Pagination Woes: losing the $masters->links() functionality

I need some pagination help … I have a table of 12,000+ records and without pagination, it is killing RAM. BUT I have to pass each through a transformer to process before loading and when I do the following I lose the $masters->link().

public function master_control()
    {
        $masters = [];
        $parts = EcoComponentMaster::where('description', '!=', 'DISCARDED')
            ->orderBy('model_value', 'desc')
            ->paginate(100);

        foreach($parts as $master) {
            $master = (new EcoComponentMastersTransformer)->transform($master);
            $masters[] = $master;
        } // end foreach

//        return $masters;

        return view('aeroeco.master_control', compact('masters'));
    } // end function
0 likes
2 replies
jlrdw's avatar

See if chunk will help you, it's in the documentation.

Snapey's avatar

Why not also pass $parts to the view and call $parts->links() instead of masters->links ?

You can still use $masters for the actual presentation of the data

Please or to participate in this conversation.