This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services\Mobile\ConectaCidadao\ExclusaoConta;
|
||||
|
||||
use App\Models\Cadastro\SujeitoAtencao\Paciente;
|
||||
use App\Services\Service;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class ExclusaoContaService extends Service
|
||||
{
|
||||
public static function excluirConta(int $id): array
|
||||
{
|
||||
$paciente = Paciente::find($id);
|
||||
|
||||
if (!$paciente) {
|
||||
|
||||
abort(Response::HTTP_NOT_FOUND, 'Paciente não encontrado.');
|
||||
}
|
||||
|
||||
if (auth('mobile')->user()->id !== $paciente->id) {
|
||||
|
||||
abort(Response::HTTP_FORBIDDEN, 'Acesso negado.');
|
||||
}
|
||||
|
||||
$paciente->update(['senha' => null]);
|
||||
|
||||
return [
|
||||
'message' => 'Conta excluída com sucesso.'
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user