0
I have created a filter screen and paginate of the Laravel.
The filters are all working, but I need that after I go to page 2, continue the filters I put.
And when I put the filters in, they’re gone.
View:
<div class="row">
<div class="col-lg-12">
<div class="padding-panel-default">
<div class="row">
<form action="{!! url('/lms/disciplinas') !!}" method="post">
{!! csrf_field() !!}
<div class="col-xs-12 col-sm-3 col-md-2">
<label for="nivel_ensino">Nível de Ensino</label>
<select name="nivel_ensino" id="nivel_ensino" class="form-control">
<option value="">Selecione</option>
@php
$arrNiveis = [];
@endphp
@foreach ($disciplinas as $disciplina)
@if (!in_array($disciplina->nivel, $arrNiveis))
@php
$arrNiveis[] = $disciplina->nivel;
@endphp
<option value="{{$disciplina->nivel}}">{{$disciplina->nivel}}</option>
@endif;
@endforeach
@php
unset($arrNiveis);
@endphp
</select>
</div>
<div class="col-xs-12 col-sm-3 col-md-2">
<label for="modalidade">Modalidade</label>
<select name="modalidade" id="modalidade" class="form-control">
<option value="">Selecione</option>
@php
$arrModalidade = [];
@endphp
@foreach ($disciplinas as $disciplina)
@if (!in_array($disciplina->modalidade, $arrModalidade))
@php
$arrModalidade[] = $disciplina->modalidade;
@endphp
<option value="{{$disciplina->modalidade}}">{{$disciplina->modalidade}}</option>
@endif;
@endforeach
@php
unset($arrModalidade);
@endphp
</select>
</div>
<div class="col-xs-12 col-sm-3 col-md-2">
<label for="periodo">Período</label>
<select name="semestre" id="semestre" class="form-control" >
<option value="">Selecione</option>
@php
$arrSemestre = [];
@endphp
@foreach ($disciplinas as $disciplina)
@if (!in_array($disciplina->semestre, $arrSemestre))
@php
$arrSemestre[] = $disciplina->semestre;
@endphp
<option value="{{$disciplina->semestre}}">{{$disciplina->semestre}}</option>
@endif;
@endforeach
@php
unset($arrSemestre);
@endphp
</select>
</div>
<div class="col-xs-12 col-sm-3 col-md-2">
<label for="periodo">Nome da Disciplina</label>
<select name="disciplina" id="disciplina" class="form-control">
<option value="">Selecione</option>
<?php
$arrDisciplinas = [];
foreach ($disciplinas as $disciplina) :
if (!in_array($disciplina->description, $arrDisciplinas)) :
$arrDisciplinas[] = $disciplina->description; ?>
<option value="<?= $disciplina->description; ?>"><?= $disciplina->description; ?></option>
<?php endif; endforeach; unset($arrDisciplinas);?>
</select>
</div>
<button>Filtro</button>
</form>
</div>
</div>
<div class="padding-panel-default">
<div ng-init="disciplinas = {{ json_encode($teste['data'])}}">
<div class="row" >
<div class="col s12 m6 l4 xl3" ng-repeat="disciplina in disciplinas">
<div class="card card-content-admin @{{ disciplina.classDiscipline }} hoverable">
<div class="card-content card-content-disciplinas" ng-class="{'tooltipped': disciplina.statusacademico == 'inativa'}">
<p class="card-title truncate">
<div class="valign-wrapper">
<h4 class="text-center">@{{ disciplina.title }}
<br>
<small><b>@{{ disciplina.numerodaturma }}</b></small>
<br>
<small>@{{ disciplina.modalidade }}</small>
</h4>
</div>
</p>
</div>
<div class="card-action acoes">
<div class="row">
<div class="col s12 text-center">
@if(\Auth()->user()->roles()->first()->role_type == "student")
<a href="{{URL_STUDENT_LMS_CATEGORIES_VIEW}}@{{ disciplina.slug }}" class="tooltipped" data-position="top" data-delay="50" data-tooltip="Acessar as Aulas"><i class="fa fa-external-link"></i></a>
<a href="https://drive.google.com/drive/folders/@{{ disciplina.drive_folder }}" class="tooltipped" data-position="top" data-delay="50" data-tooltip="Acessar o Drive"><i class="fa fa-folder"></i></a>
@else
<a href="{{URL_LMS_AULAS}}@{{ disciplina.slug }}" class="tooltipped" data-position="top" data-delay="50" data-tooltip="Acessar as Aulas"><i class="fa fa-external-link"></i></a>
<a href="https://drive.google.com/drive/folders/@{{ disciplina.drive_folder }}" class="tooltipped" data-position="top" data-delay="50" data-tooltip="Acessar o Drive" target="_blank"><i class="fa fa-folder"></i></a>
@endif
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
if(Auth()->user()->roles()->first()->role_type != "student") {
?>
<div class="fixed-action-btn toolbar hide-on-med-and-up click-to-toggle">
<a class="btn-floating btn-large red z-depth-4">
<i class="large material-icons">reorder</i>
</a>
<ul>
<li class="tooltipped" data-position="top" data-delay="50" data-tooltip="Relatórios"><a href="#" class="btn-floating waves-effect waves-light"><i class="fa fa-bar-chart"></i></a></li>
<li class="tooltipped" data-position="top" data-delay="50" data-tooltip="Configuração Composição de Notas"><a href="#" class="btn-floating waves-effect waves-light"><i class="fa fa-cog"></i></a></li>
<li class="tooltipped" data-position="top" data-delay="50" data-tooltip="Notificações"><a href="{{URL_NOTIFICACOES_DISCIPLINAS}}" class="btn-floating waves-effect waves-light"><i class="fa fa-warning"></i></a></li>
</ul>
</div>
<div class="fixed-action-btn vertical hide-on-small-only click-to-toggle">
<a class="btn-floating btn-large red z-depth-4">
<i class="large material-icons">reorder</i>
</a>
<ul class="btn-floating-icon-fa">
<li class="tooltipped" data-position="left" data-delay="50" data-tooltip="Relatórios"><a href="#" class="btn-floating brown darken-1 waves-effect waves-light"><i class="fa fa-bar-chart"></i></a></li>
<li class="tooltipped" data-position="left" data-delay="50" data-tooltip="Configuração Composição de Notas"><a href="<?= URL_LMS_NOTAS; ?>" class="btn-floating orange darken-1 waves-effect waves-light"><i class="fa fa-cog"></i></a></li>
<li class="tooltipped" data-position="left" data-delay="50" data-tooltip="Notificações"><a href="{{URL_NOTIFICACOES_DISCIPLINAS}}" class="btn-floating blue darken-1 waves-effect waves-light"><i class="fa fa-warning"></i></a></li>
</ul>
</div>
<?php } ?>
{{ $paginate->links() }}
</div>
</div>
</div>
Controller:
/busca os imputs do filtro
$semestre = Input::get('semestre');
$modalidade = Input::get('modalidade');
$nivel = Input::get('nivel');
$disciplina = Input::get('disciplina');
// faz validacao pra ver se é aluno ou professor
if (Auth()->User()->role->role_type == 'admin' || Auth()->User()->role->role_type == 'owner') {
$records = LmsDisciplines::select(['lmsdisciplines.*', 'modalidade.name as modalidade', 'nivel.name as nivel'])//aqui busca os filtros
->join('modalidade', 'lmsdisciplines.modalidade_id', '=', 'modalidade.id')
->join('nivel', 'lmsdisciplines.nivel_id', '=', 'nivel.id')
->where([['lmsdisciplines.id', '<>', '1']])
->get();
$disciplina = LmsDisciplines::select(['lmsdisciplines.*', 'modalidade.name as modalidade', 'nivel.name as nivel'])//aqui monta paginate
->join('modalidade', 'lmsdisciplines.modalidade_id', '=', 'modalidade.id')
->join('nivel', 'lmsdisciplines.nivel_id', '=', 'nivel.id')
->where([['lmsdisciplines.id', '<>', '1'],
['semestre', 'like', '%'.$semestre.'%'],
['modalidade.name', 'like', '%'.$modalidade.'%'],
['nivel.name', 'like', '%'.$nivel.'%'],
['title', 'like', '%'.$disciplina.'%']])
->paginate(24);
} else {
$records = LmsDisciplines::disciplineUsers(Auth::user()->id);
}
Where is your paging view.?
– novic