67 lines
1.8 KiB
PHP
67 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Cadastro;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Services\Cadastro\OrigemProgramaticaService;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Response;
|
|
|
|
class OrigemProgramaticaController extends Controller
|
|
{
|
|
protected $modulo = 'cadastro';
|
|
protected $funcionalidade = 'origem-programatica';
|
|
|
|
public function create()
|
|
{
|
|
$this->auth(__FUNCTION__);
|
|
|
|
return response()->json(OrigemProgramaticaService::create(), Response::HTTP_OK);
|
|
}
|
|
|
|
public function store(Request $request)
|
|
{
|
|
$this->auth(__FUNCTION__);
|
|
|
|
return response()->json(OrigemProgramaticaService::store($request), Response::HTTP_CREATED);
|
|
}
|
|
|
|
public function edit($id)
|
|
{
|
|
$this->auth(__FUNCTION__);
|
|
|
|
return response()->json(OrigemProgramaticaService::edit($id), Response::HTTP_OK);
|
|
}
|
|
|
|
public function update(Request $request, $id)
|
|
{
|
|
$this->auth(__FUNCTION__);
|
|
|
|
return response()->json(OrigemProgramaticaService::update($request, $id), Response::HTTP_OK);
|
|
}
|
|
|
|
public function destroy($id)
|
|
{
|
|
$this->auth(__FUNCTION__);
|
|
|
|
return response()->json(OrigemProgramaticaService::destroy($id), Response::HTTP_NO_CONTENT);
|
|
}
|
|
|
|
public function datatable()
|
|
{
|
|
return datatables()
|
|
->of(OrigemProgramaticaService::datatable())
|
|
->filterColumn('cadastro_origem_programatica.ativo', function ($query, $keyword) {
|
|
$query->whereRaw("CASE WHEN cadastro_origem_programatica.ativo THEN 'Sim' ELSE 'Não' END LIKE ?", ["%{$keyword}%"]);
|
|
})
|
|
->make(true);
|
|
}
|
|
|
|
public function autocomplete()
|
|
{
|
|
return datatables()
|
|
->of(OrigemProgramaticaService::autocomplete())
|
|
->make(true);
|
|
}
|
|
}
|