Paginate Updating Requisition?

0

Good morning, I will try to simplify my difficulty, however any extra doubt I will be available to provide any information of the code ...

I have a filter whose I do my searches for certain values and in the end I have a paginate value:

<div class="form-group col-md-12 col-sm-12 col-xs-12">
    <div class="col-md-2 col-sm-2 col-xs-2 form-label">
        {{Form::label('poder', 'Poder')}}
    </div>
    <div class="col-md-10 col-sm-10 col-xs-10">
        {{Form::select('poder', $poder, null, ['class' => 'form-control'])}}
    </div>
</div>
<div class="form-group col-md-12 col-sm-12 col-xs-12">
    <div class="col-md-2 col-sm-2 col-xs-2 form-label">
        {{Form::label('unidade', 'Unidade')}}
    </div>
    <div class="col-md-10 col-sm-10 col-xs-10">
        {{Form::select('unidade', $unidade, null, ['class' => 'form-control'])}}
    </div>
</div>
<div class="form-group col-md-12 col-sm-12 col-xs-12">
            {{Form::label('perPage', 'Deseja filtrar quantos resultados por página?', ['class' => 'pagilabel'])}}
            {{Form::number('perPage', null, ['class' => 'paginumber', 'min' => 0])}}
            {{Form::submit('Localizar', ['class' => 'btn btn-info'])}}
 </div>

In my controller I have the following:

if ($request->poder) $query->where('orgao.poderId', $request->poder);
if ($request->unidade) $query->where('unid.id', $request->unidade);
$table = $query->paginate($request->perPage ? $request->perPage : 20);

I have determined a default value of 20 results per page by paginate, everything works perfectly ....

My difficulty is ...: When I command to filter a certain result, when changing page by paginate the request is canceled and shows all the records of my respective table, as if my filter was canceled and the page updated. / p>

My question is ...: How do I send the same request made by the form every time I change the paginate page?

Thank you in advance!

    
asked by anonymous 06.07.2016 / 16:51

1 answer

2

just add with appends

{!! $table->appends(['poder' => $poder])->render() !!}
    
08.07.2016 / 03:49