This commit is contained in:
88
api/app/Http/Controllers/Cadastro/OciController.php
Normal file
88
api/app/Http/Controllers/Cadastro/OciController.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Cadastro;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Services\Cadastro\OciService;
|
||||
use App\Utils\MaskUtil;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class OciController extends Controller
|
||||
{
|
||||
protected $modulo = 'cadastro';
|
||||
protected $funcionalidade = 'oci';
|
||||
|
||||
public function datatable()
|
||||
{
|
||||
return datatables()
|
||||
->of(OciService::datatable())
|
||||
->filterColumn('procedimento_descricao', function ($query, $keyword) {
|
||||
|
||||
$query
|
||||
->whereRaw("CONCAT(procedimento.codigo, ' - ', procedimento.nome) like ?", ["%{$keyword}%"])
|
||||
->orWhereRaw(
|
||||
"CONCAT(
|
||||
CONCAT(
|
||||
SUBSTR(procedimento_codigo,1,2),
|
||||
'.',
|
||||
SUBSTR(procedimento_codigo,3,2),
|
||||
'.',
|
||||
SUBSTR(procedimento_codigo,5,2),
|
||||
'.',
|
||||
SUBSTR(procedimento_codigo,7,3),
|
||||
'-',
|
||||
SUBSTR(procedimento_codigo,10,1)
|
||||
),
|
||||
' - ',
|
||||
procedimento.nome
|
||||
) like ?",
|
||||
["%{$keyword}%"]
|
||||
);
|
||||
})
|
||||
->addColumn('procedimento_descricao', fn ($oci) =>
|
||||
MaskUtil::getProcedimentoMasked($oci->procedimento_codigo) . " - {$oci->procedimento_nome}")
|
||||
->toJson();
|
||||
}
|
||||
|
||||
public function list()
|
||||
{
|
||||
return response()->json(OciService::list(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(OciService::create(), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(OciService::store(), Response::HTTP_CREATED);
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(OciService::edit($id), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function update($id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
return response()->json(OciService::update($id), Response::HTTP_OK);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
$this->auth(__FUNCTION__);
|
||||
|
||||
OciService::destroy($id);
|
||||
|
||||
return response()->noContent();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user