This commit is contained in:
105
api/app/Http/Controllers/Cadastro/EspecialidadeController.php
Normal file
105
api/app/Http/Controllers/Cadastro/EspecialidadeController.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Cadastro;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Cadastro\EspecialidadeService;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class EspecialidadeController extends Controller
|
||||
{
|
||||
protected $modulo = 'cadastro';
|
||||
protected $funcionalidade = 'especialidade';
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
return datatables()
|
||||
->of(EspecialidadeService::datatable())
|
||||
->filterColumn('ocupacao_descricao', function ($query, $keyword) {
|
||||
|
||||
$query->whereRaw("CONCAT(ocupacao.codigo, ' - ', ocupacao.nome) like ?", ["%{$keyword}%"]);
|
||||
})
|
||||
->filterColumn('permite_integracao_conectasus_cidadao', function ($query, $keyword) {
|
||||
|
||||
$value = mb_strtolower($keyword, 'UTF-8');
|
||||
if (str_contains($value, 'sim')) {
|
||||
$query->where('especialidade.permite_integracao_conectasus_cidadao', true);
|
||||
} elseif (str_contains($value, 'não') || str_contains($value, 'nao')) {
|
||||
$query->where('especialidade.permite_integracao_conectasus_cidadao', false);
|
||||
}
|
||||
})
|
||||
->toJson();
|
||||
}
|
||||
|
||||
public function autocomplete()
|
||||
{
|
||||
return datatables()
|
||||
->of(EspecialidadeService::autocomplete())
|
||||
->toJson();
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(EspecialidadeService::create(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(EspecialidadeService::store(), Response::HTTP_CREATED);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(EspecialidadeService::edit($id), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function update($id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(EspecialidadeService::update($id), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function activate($id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(EspecialidadeService::activate($id), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function deactivate($id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(EspecialidadeService::deactivate($id), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
EspecialidadeService::destroy($id);
|
||||
|
||||
return response()->noContent();
|
||||
}
|
||||
|
||||
public function getDadosParaAtribuicao()
|
||||
{
|
||||
return response()->json(EspecialidadeService::getDadosParaAtribuicao(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function saveAtribuicao()
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
EspecialidadeService::saveAtribuicao();
|
||||
|
||||
return response()->noContent();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user