Support the ongoing development of Laravel.io →
Input Eloquent Views
Last updated 1 year ago.
0

I am not sure of exactly what you are doing, but I paginate all the time like this and it works:
Controller

public function ownerlist()
	{
	
        if(isset($_REQUEST['t1']))
        {
            $t1 = $_REQUEST['t1'];
        }
        else
        {
            $t1 = "";
        }
        $ownersearch = $t1;
        $ownersearch = $ownersearch . "%";
        
        $data['owners'] = DB::table('powners')
                        ->where('oname', 'like', $ownersearch)
                        ->orderBy('oname', 'asc')
                        ->Paginate(5);
        $data['osearch'] = $t1;
        return View::make('owner/pownerlist')->with('data', $data['owners'])->with('data2', $data['osearch']);
       
	}

And in view do the links:

<div class="pagination" style="margin-left: 20px; margin-right: auto; width: 800px; border:solid red; display:  block;">
      <?php echo $data->appends(array('t1' => $data2))->links(); ?> 
</div>

This is assuming you are using laravel 4.2.

0

Hi jimgwhit, thanks for the reply.

Yes I am using L4.2, but my problem is not in appending simple queries (as key=value ) to the paginator, but in appending array of queries (as key[]=value1&key[]=value2 ).

0

I just tested by adding another to my array, worked like a champ:

<?php echo $data->appends(array('t1' => $data2, 't2' => 'worked'))->links(); ?>
0

jimgwhit said:

I just tested by adding another to my array, worked like a champ:

<?php echo $data->appends(array('t1' => $data2, 't2' => 'worked'))->links(); ?>

Thanks for the reply. Again, I use Input::query() to the appends method and I think that's my real problem. I tried Request::except('page') but I have always the same problem... which is:

When I do a var_dump to Input::query() in the first page, I got:

array (size=1)
  'param' => 
    array (size=2)
      0 => string 'value1' (length=6)
      1 => string 'value2' (length=6)

An when I do it after pagination, I got:

array (size=3)
  0 => 
    array (size=2)
      0 => string 'value1' (length=6)
      1 => string 'value2' (length=6)
  'page' => string '2' (length=1)

I lost the key "param"

Last updated 9 years ago.
0

What is the Input::query() thing?
You aren't trying to send the checkboxs in the appends are you?
The appends is to send any extra data from page to page, not your form submission.
Change the method to post. I think you mis-understand what the appends is for.
Say you were paging with a search, you use the appends to carry forward the search criteria, that
would be an example.
Look at my example above again, I could be paging 10000 owners, the t1 carries forward the search.
Your form looks like an input form, not a listing where pagination is taking place.

Last updated 9 years ago.
0

Problem solved, used Request::query() instead of Input::all() in the action. Thanks "everybody" ^^.

jubayermasum liked this reply

1

Sign in to participate in this thread!

Eventy

Your banner here too?

othmanus othmanus Joined 23 Jul 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.