Hey,
Can you not echo out the links in the view, somethings like this
{{ $users->appends(['sort' => 'votes'])->links() }}
The docs cover it pretty well: https://laravel.com/docs/5.3/pagination
I know my threads subjects may confuse some of you, but let me explain a bit better:
I've the resourceful route:
Route::resource('deposits', 'DepositsController');
So in order to show all deposits I ofcurse visit the URI:
url.com/deposits
And at the bottom I've the pagination feature (using "render"), that redirect to the deisred page, for instance:
url.com/deposits?page=2
So far, all good, now lets take it a bit further, I've built a sorting feature that look for attributes in the URI and sorting the results accordingly, so for example:
url.com/deposits?employee=1&flag=&deposit_type=&documents=&client_name=&phone=&comment=&id=&amount_from=&amount_to=&datePicker=&amount=&creation_date=
Will display records according to the attributes, so far, again, it's all good!
The problem starts when the there are more than 10 records (which I've defined this amount earlier) it still redirect to:
url.com/deposits?page=2
Instead of
url.com/deposits?employee=1&flag=&deposit_type=&documents=&client_name=&phone=&comment=&id=&amount_from=&amount_to=&datePicker=&amount=&creation_date=&page=2
And this is how the deposits sorting is written:
$deposits = Deposit::filterBy(
[
'id' => urlParamOrNull('id'),
'employee_id' => urlParamOrNull('employee'),
'type_id' => urlParamOrNull('deposit_type'),
'amount' => urlParamOrNull('amount'),
'amountOperator' => urlParamOrNull('amount_operator'),
'flag_id' => urlParamOrNull('flag'),
'comment' => urlParamOrNull('comment'),
'client_name' => urlParamOrNull('client_name'),
'phone' => urlParamOrNull('phone'),
'documents' => urlParamOrNull('documents'),
'created_at' => urlParamOrNull('creation_date'),
])
->orderBy('created_at', 'desc')
->paginate($this->recordsPerPage);
Can you please try to help me our? how can I define that the paginate will add the page attribute to the end of the URI and won't change it completely to the actual route path + the page number?
Thanks once again!
Hey,
Can you not echo out the links in the view, somethings like this
{{ $users->appends(['sort' => 'votes'])->links() }}
The docs cover it pretty well: https://laravel.com/docs/5.3/pagination
Please or to participate in this conversation.