1
Controller:
public function get(Request $request, Funcionario $funcionarios)
{
if ($funcionarios->id) {
return response()->json(['data' =$funcionarios->toArray()]);
}
$rules = [
'nome' =['type' ='string', 'op' ='like', 'prefix' ='%', 'suffix' ='%'],
'celular' =['type' ='string', 'op' ='like', 'prefix' ='%', 'suffix' ='%'],
'telefone' =['type' ='string', 'op' ='like', 'prefix' ='%', 'suffix' ='%'],
'email' =['type' ='string', 'op' ='like', 'prefix' ='%', 'suffix' ='%'],
'idprofessor' =['type' ='integer', 'op' ='=', 'prefix' ='', 'suffix' ='']
];
$query = Funcionario::query();
$query = Utils::orderBy($query, $request->get('order'));
$query = Utils::filter($query, $request->get('filter', []), $rules);
return response()->json($query->paginate($request->get('limit')));
}
View VUE
activeOptions: [{ label: 'Todos', key: '' }, { label: 'Colaboradores',
key: 'NULL' }, { label: 'Docentes', key: '' }],
<div class="filter-container" <el-input
:placeholder="$t('employee.name')" v-model="listQuery.filter.nome"
style="width: 200px;" class="filter-item"
@keyup.enter.native="handleFilter"/>
<el-input :placeholder="$t('employee.cell')" v-model="listQuery.filter.celular" style="width: 200px;"
class="filter-item" @keyup.enter.native="handleFilter"/>
<el-input :placeholder="$t('employee.phone')" v-model="listQuery.filter.telefone" style="width: 200px;"
class="filter-item" @keyup.enter.native="handleFilter"/>
<el-select v-model="listQuery.filter.jacad_idprofessor" clearable style="width: 140px" class="filter-item"
@change="handleFilter">
<el-option v-for="item in activeOptions" :key="item.key" :label="item.label" :value="item.key"/>
</el-select>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">{{ $t('table.search')
}}</el-button>
<el-button v-waves :loading="downloadLoading" class="filter-item" type="primary" icon="el-icon-download"
@click="handleDownload">{{ $t('table.export') }}</el-button>
<router-link target="_blank" to="/employee/printer">
<el-button type="primary" class="filter-item" icon="el-icon-printer">{{ $t('table.printer') }}</el-button>
</router-link>
</div>
I need to bring, in select the Collaborators who are NULL
and teachers who are not null
, that field is integer
.