简体   繁体   中英

Pagination in laravel gives me error “Undefined offset: 1”

my controller code is

$enquiries = Enquiry::paginate(5);
return view('admin.enquiry-list')->withResults($enquiries);

my blade.php code is like this

{{ $enquiries->appends(Request::only('fullname',
            'mobile',
            'email'))->links() }}

where am i doing wrong?

the links should not be treated as an html entity

 $enquiries = Enquiry::paginate(5);
    return view('admin.enquiry-list')->with('enquiries',$enquiries);

    {!! $enquiries->appends(Request::only('fullname',
                'mobile',
                'email'))->links() !!}

If you refer to Laravel documentation, here Is what it says:

Appending To Pagination Links

You may append to the query string of pagination links using the appends method. For example, to append sort=votes to each pagination link, you should make the following call to appends:

{{ $users->appends(['sort' => 'votes'])->links() }}

Based on it I feel what you are missing is Parameters supplied to the appends should be array. Can you try changing it to an Array ?

{{ $enquiries->appends(Request::only(['fullname',
        'mobile',
        'email']))->links() }}

Can you try checking if this works ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM