Files
Antonio Lopes dos Santos afec302c3e
All checks were successful
build-api-image / build (push) Successful in 51s
init commit
2026-08-04 16:52:02 -03:00

32 lines
709 B
PHP

<?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.'
];
}
}