init commit
All checks were successful
build-api-image / build (push) Successful in 51s

This commit is contained in:
Antonio Lopes dos Santos
2026-08-04 16:52:02 -03:00
commit afec302c3e
11594 changed files with 1636728 additions and 0 deletions

View File

@@ -0,0 +1,77 @@
<?php
namespace App\Services\ProntoAtendimento\PedidoExame;
use App\Models\ProntoAtendimento\PedidoExame\Laudo;
use App\Services\Service;
class LaudoService extends Service
{
public function storeFile($pedido, $files, $additionalsParams = [])
{
foreach (['pedido_exame_id', 'hash', 'nome'] as $field) {
if (array_key_exists($field, $additionalsParams)) {
unset($additionalsParams[$field]);
}
}
$path = storage_path( 'pronto-atendimento'
. DIRECTORY_SEPARATOR
. 'laudos'
. DIRECTORY_SEPARATOR
. app('config')->get('database.default')
. DIRECTORY_SEPARATOR
. $pedido->id
);
if($files)
{
foreach($files as $file)
{
$data = (new \DateTime)->getTimestamp();
$extensao = $file->extension();
$arquivo = encrypt($data) . '.' . $extensao;
$request['hash'] = $arquivo;
$request['nome'] = mb_strtoupper($file->getClientOriginalName());
$file->move($path, $arquivo);
Laudo::create(array_merge([
'pedido_exame_id' => $pedido->id,
'hash' => $request['hash'],
'nome' => $request['nome']
], $additionalsParams));
}
}
}
public function destroy($id)
{
return Laudo::findOrFail($id)->delete();
}
public function download($id, string $hash)
{
$laudo = Laudo::findOrFail($id);
$path = storage_path( 'pronto-atendimento'
. DIRECTORY_SEPARATOR
. 'laudos'
. DIRECTORY_SEPARATOR
. app('config')->get('database.default')
. DIRECTORY_SEPARATOR
. $laudo->pedido_exame_id
. DIRECTORY_SEPARATOR
) . $hash;
$headers = [
'Content-Type' => 'application/pdf',
];
return [
'path' => $path,
'nome' => $laudo->nome,
'headers' => $headers
];
}
}