32 lines
709 B
PHP
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.'
|
|
];
|
|
}
|
|
}
|