114 lines
2.7 KiB
PHP
114 lines
2.7 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Ambulatorio;
|
|
|
|
use App\Exceptions\Ambulatorio\FimExcedeuDataJornadaException;
|
|
use App\Exceptions\Ambulatorio\JornadaConflitanteException;
|
|
use App\Exceptions\Ambulatorio\PossuiAgendamentoException;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Rules\Cns;
|
|
use App\Services\Ambulatorio\JornadaService;
|
|
use Illuminate\Http\Response;
|
|
|
|
class JornadaController extends Controller
|
|
{
|
|
protected $modulo = 'ambulatorio';
|
|
protected $funcionalidade = 'jornada';
|
|
|
|
public function datatable()
|
|
{
|
|
return JornadaService::datatable();
|
|
}
|
|
|
|
public function index()
|
|
{
|
|
$this->auth(__FUNCTION__);
|
|
|
|
return response()->json(JornadaService::index(), Response::HTTP_OK);
|
|
}
|
|
|
|
public function create()
|
|
{
|
|
$this->auth(__FUNCTION__);
|
|
|
|
return response()->json(JornadaService::create(), Response::HTTP_OK);
|
|
}
|
|
|
|
public function edit($id)
|
|
{
|
|
$this->auth(__FUNCTION__);
|
|
|
|
return response()->json(JornadaService::edit($id), Response::HTTP_OK);
|
|
}
|
|
|
|
public function list()
|
|
{
|
|
return response()->json(JornadaService::list(), Response::HTTP_OK);
|
|
}
|
|
|
|
public function store()
|
|
{
|
|
$this->auth(__FUNCTION__);
|
|
|
|
try {
|
|
|
|
return response()->json(JornadaService::store(), Response::HTTP_CREATED);
|
|
}
|
|
catch (FimExcedeuDataJornadaException $e) {
|
|
|
|
return response()->json(['message' => $e->getMessage()], Response::HTTP_BAD_REQUEST);
|
|
}
|
|
}
|
|
|
|
public function update($id)
|
|
{
|
|
$this->auth(__FUNCTION__);
|
|
|
|
try {
|
|
|
|
return response()->json(JornadaService::update($id), Response::HTTP_OK);
|
|
}
|
|
catch (JornadaConflitanteException | PossuiAgendamentoException | FimExcedeuDataJornadaException $e) {
|
|
|
|
return response()->json(['message' => $e->getMessage()], Response::HTTP_BAD_REQUEST);
|
|
}
|
|
}
|
|
|
|
public function updateAll()
|
|
{
|
|
$this->auth(__FUNCTION__);
|
|
|
|
try {
|
|
|
|
return response()->json(JornadaService::updateAll(), Response::HTTP_OK);
|
|
}
|
|
catch (FimExcedeuDataJornadaException $e) {
|
|
|
|
return response()->json(['message' => $e->getMessage()], Response::HTTP_BAD_REQUEST);
|
|
}
|
|
}
|
|
|
|
public function destroy($id)
|
|
{
|
|
$this->auth(__FUNCTION__);
|
|
|
|
try {
|
|
|
|
JornadaService::destroy($id);
|
|
|
|
return response()->noContent();
|
|
}
|
|
catch (PossuiAgendamentoException $e) {
|
|
|
|
return response()->json(['message' => $e->getMessage()], Response::HTTP_BAD_REQUEST);
|
|
}
|
|
}
|
|
|
|
public function destroyAll()
|
|
{
|
|
$this->auth(__FUNCTION__);
|
|
|
|
return response()->json(JornadaService::destroyAll(), Response::HTTP_OK);
|
|
}
|
|
}
|