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 ]; } }