deepu07
1 month ago
324
8
Laravel

Laravel Pagination render()

Posted 1 month ago by deepu07

Hi Guys, In my project, I'm getting this error

ErrorException (E_ERROR)
Call to undefined method stdClass::render() (View:

Where I'm using custom pagination where After combining two objects in my code applying pagination. here is my pagination code

public function paginateWithoutKey($items, $perPage = 15, $page = null, $options = [])
    {
        $page = $page ?: (Paginator::resolveCurrentPage() ?: 1);

        $items = $items instanceof Collection ? $items : Collection::make($items);

        $lap = new LengthAwarePaginator($items->forPage($page, $perPage), $items->count(), $perPage, $page, $options);

        $res = [
            'current_page' => $lap->currentPage(),
            'data' => $lap->values(),
            'first_page_url' => $lap->url(1),
            'from' => $lap->firstItem(),
            'last_page' => $lap->lastPage(),
            'last_page_url' => $lap->url($lap->lastPage()),
            'next_page_url' => $lap->nextPageUrl(),
            'per_page' => $lap->perPage(),
            'prev_page_url' => $lap->previousPageUrl(),
            'to' => $lap->lastItem(),
            'total' => $lap->total(),
        ];

        return json_decode(json_encode($res));
    }

I'm looping data in blade file and everything working except page links {{ $data->render() }}. can anyone help me on this i.e. how to resolve this issue. Thanks in advance.

Please sign in or create an account to participate in this conversation.