Arreglo a imagenes y al searchRecord

This commit is contained in:
Juan Felipe Zapata Moreno 2025-10-29 15:58:07 -06:00
parent 41c85a8ade
commit d7761088dd
6 changed files with 39 additions and 81 deletions

View File

@ -45,7 +45,7 @@ server {
# Handle storage files (Laravel storage link) # Handle storage files (Laravel storage link)
location /storage { location /storage {
alias /var/www/repuve-backend-v1/storage/app; alias /var/www/repuve-backend-v1/storage/app/public;
try_files $uri =404; try_files $uri =404;
} }

View File

@ -350,9 +350,9 @@ public function searchRecord(Request $request)
$request->validate([ $request->validate([
'folio' => 'nullable|string', 'folio' => 'nullable|string',
'placa' => 'nullable|string', 'placa' => 'nullable|string',
'niv' => 'nullable|string', 'vin' => 'nullable|string',
], [ ], [
'required_without_all' => 'Debe proporcionar al menos uno de los siguientes: folio, placa o NIV.' 'required_without_all' => 'Debe proporcionar al menos uno de los siguientes: folio, placa o vin.'
]); ]);
$query = Record::with(['vehicle.owner', 'vehicle.tag', 'files', 'user', 'error'])->orderBy('id', 'ASC'); $query = Record::with(['vehicle.owner', 'vehicle.tag', 'files', 'user', 'error'])->orderBy('id', 'ASC');
@ -365,9 +365,9 @@ public function searchRecord(Request $request)
$query->whereHas('vehicle', function ($q) use ($request) { $query->whereHas('vehicle', function ($q) use ($request) {
$q->where('placa', 'LIKE', '%' . $request->input('placa') . '%'); $q->where('placa', 'LIKE', '%' . $request->input('placa') . '%');
}); });
} elseif ($request->filled('niv')) { } elseif ($request->filled('vin')) {
$query->whereHas('vehicle', function ($q) use ($request) { $query->whereHas('vehicle', function ($q) use ($request) {
$q->where('numero_serie', 'LIKE', '%' . $request->input('niv') . '%'); $q->where('numero_serie', 'LIKE', '%' . $request->input('vin') . '%');
}); });
} }
@ -418,7 +418,6 @@ public function searchRecord(Request $request)
'name' => $file->name, 'name' => $file->name,
'path' => $file->path, 'path' => $file->path,
'url' => $file->url, 'url' => $file->url,
'md5' => $file->md5,
]; ];
}), }),
]; ];
@ -437,35 +436,35 @@ public function searchRecord(Request $request)
private function getVehicle(): array private function getVehicle(): array
{ {
return [ return [
"ANIO_PLACA" => "2021", "ANIO_PLACA" => "2023",
"PLACA" => "WNU700A", "PLACA" => "WXY-789-Z",
"NO_SERIE" => "LSGHD52H0ND032458", "NO_SERIE" => "9KLMNP8R7ST234567",
"RFC" => "GME111116GJA", "RFC" => "SDE010203XYZ",
"FOLIO" => "EXP-2025-201030", "FOLIO" => "54321",
"VIGENCIA" => "2025", "VIGENCIA" => "2026",
"FECHA_IMPRESION" => "10-01-2025", "FECHA_IMPRESION" => "15-03-2024",
"QR_HASH" => "Vu5TF4kYsbbltzjDdGQyenKfZoIk2wro34a5Gkh9JVh0CFxfPlrd92YEWK21JF.nLjQNyzKmqRvWYuPiS.kU7A--", "QR_HASH" => "Abc123Def456Ghi789Jkl0MnOpQrStUvWxYzZaBcDeFgHiJkLmNoPqRsTuVwXyZ",
"VALIDO" => true, "VALIDO" => true,
"FOLIOTEMP" => false, "FOLIOTEMP" => false,
"NOMBRE" => "GOLSYSTEMS DE MEXICO S DE RL DE CV", "NOMBRE" => "SERVICIOS INFORMATICOS DEL GOLFO SA DE CV",
"NOMBRE2" => "GOLS*MS DXICOE RL*CV", "NOMBRE2" => "SERVI*IOS I*TICOSLFO SA*CV",
"MUNICIPIO" => "CENTRO", "MUNICIPIO" => "CARDENAS",
"LOCALIDAD" => "VILLAHERMOSA", "LOCALIDAD" => "HEROICA CARDENAS",
"CALLE" => "C BUGAMBILIAS 118 ", "CALLE" => "AV. LAZARO CARDENAS 200",
"CALLE2" => "C BU*ILIA*18 ", "CALLE2" => "AV. LA*RO CA*NAS 2*0",
"TIPO" => "SEDAN", "TIPO" => "SUV",
"TIPO_SERVICIO" => "PARTICULAR", "TIPO_SERVICIO" => "PARTICULAR",
"MARCA" => "CHEVROLET G.M.C.", "MARCA" => "NISSAN",
"LINEA" => "AVEO", "LINEA" => "KICKS",
"SUBLINEA" => "PAQ. \"A\" LS", "SUBLINEA" => "ADVANCE",
"MODELO" => 2022, "MODELO" => 2023,
"NUMERO_SERIE" => "LSGHD52H0ND032458", "NUMERO_SERIE" => "9KLMNP8R7ST234567",
"NUMERO_MOTOR" => "H. EN WUHANLL,SGM", "NUMERO_MOTOR" => "HR16DE123456Z",
"DESCRIPCION_ORIGEN" => "NACIONAL", "DESCRIPCION_ORIGEN" => "NACIONAL",
"COLOR" => "BLANCO", "COLOR" => "GRIS OXFORD",
"CODIGO_POSTAL" => "86179", "CODIGO_POSTAL" => "86500",
"SERIE_FOLIO" => "D3962242", "SERIE_FOLIO" => "E8765432",
"SFOLIO" => "3962242" "SFOLIO" => "8765432"
]; ];
} }

View File

@ -13,7 +13,6 @@
use App\Models\Tag; use App\Models\Tag;
use App\Models\Error; use App\Models\Error;
use Exception; use Exception;
use PhpParser\Node\Stmt\Foreach_;
class UpdateController extends Controller class UpdateController extends Controller
{ {
@ -22,15 +21,9 @@ public function vehicleData(Request $request)
{ {
try { try {
$request->validate([ $request->validate([
'folio' => 'required', 'folio' => 'required','string','exists:records,folio',
'string', 'tag_number' => 'required','string','exists:tags,tag_number',
'exists:records,folio', 'vin' => 'required','string','exists:vehicles,vin'
'tag_number' => 'required',
'string',
'exists:tags,tag_number',
'vin' => 'required',
'string',
'exists:vehicles,vin'
]); ]);
$folio = $request->input('folio'); $folio = $request->input('folio');
@ -216,14 +209,13 @@ public function vehicleUpdate(VehicleUpdateRequest $request)
$customName = str_replace(' ', '_', $customName); $customName = str_replace(' ', '_', $customName);
$extension = $file->getClientOriginalExtension(); $extension = $file->getClientOriginalExtension();
$fileName = $customName . '_' . time() . '.' . $extension; $fileName = $customName . '_' . time() . '.' . $extension;
$path = $file->storeAs('records' . $fileName, 'public'); $path = $file->storeAs('records', $fileName, 'public');
$md5 = md5_file($file->getRealPath()); $md5 = md5_file($file->getRealPath());
$fileRecord = File::create([ $fileRecord = File::create([
'record_id' => $record->id, 'record_id' => $record->id,
'name' => $fileName, 'name' => $fileName,
'path' => $path, 'path' => $path,
'url' => asset('storage/' . $path),
'md5' => $md5, 'md5' => $md5,
]); ]);
@ -231,7 +223,7 @@ public function vehicleUpdate(VehicleUpdateRequest $request)
'id' => $fileRecord->id, 'id' => $fileRecord->id,
'name' => $fileRecord->name, 'name' => $fileRecord->name,
'path' => $fileRecord->path, 'path' => $fileRecord->path,
'md5' => $fileRecord->md5, 'url' => $fileRecord->url,
]; ];
} }
} }
@ -383,40 +375,6 @@ private function sendToRepuveNacional(string $vin): array
]; ];
} }
private function getVehicle2(): array
{
return [
"ANIO_PLACA" => "2027",
"PLACA" => "WNU730X",
"NO_SERIE" => "EXP-2025-201030",
"RFC" => "GME111116GJA",
"FOLIO" => "EXP-2025-201030",
"VIGENCIA" => "2026",
"FECHA_IMPRESION" => "10-01-2025",
"QR_HASH" => "Vu5TF4kYsbbltzjDdGQyenKfZoIk2wro34a5Gkh9JVh0CFxfPlrd92YEWK21JF.nLjQNyzKmqRvWYuPiS.kU7A--",
"VALIDO" => true,
"NOMBRE" => "GOLSYSTEMS DE MEXICO S DE RL DE CV",
"NOMBRE2" => "GOLS*MS DXICOE RL*CV",
"MUNICIPIO" => "CENTRO",
"LOCALIDAD" => "VILLAHERMOSA",
"CALLE" => "C BUGAMBILIAS 119 ",
"CALLE2" => "C BU*ILIA*18 ",
"TIPO" => "SEDAN",
"TIPO_SERVICIO" => "PARTICULAR",
"MARCA" => "CHEVROLET G.M.C.",
"LINEA" => "AVEO",
"SUBLINEA" => "PAQ. \"A\" LS",
"MODELO" => 2023,
"NUMERO_SERIE" => "EXP-2025-201030",
"NUMERO_MOTOR" => "H. EN WUHANLL,SGM",
"DESCRIPCION_ORIGEN" => "IMPORTADO",
"COLOR" => "AZUL",
"CODIGO_POSTAL" => "86181",
"SERIE_FOLIO" => "D3962242",
"SFOLIO" => "EXP-2025-201030"
];
}
private function getOwner(): array private function getOwner(): array
{ {
return [ return [

View File

@ -58,8 +58,8 @@ public function definition(): array
return [ return [
'anio_placa' => (string) $year, 'anio_placa' => (string) $year,
'placa' => $placa, 'placa' => $placa . fake()->unique(),
'numero_serie' => $vin, 'numero_serie' => $vin . fake()->unique(),
'rfc' => 'GME' . fake()->numerify('######') . 'GJA', 'rfc' => 'GME' . fake()->numerify('######') . 'GJA',
'folio' => fake()->unique()->numerify('#######'), 'folio' => fake()->unique()->numerify('#######'),
'vigencia' => (string) ($year + 1), 'vigencia' => (string) ($year + 1),

View File

@ -26,6 +26,7 @@ services:
- "${NGINX_PORT}:80" - "${NGINX_PORT}:80"
volumes: volumes:
- ./public:/var/www/repuve-backend-v1/public - ./public:/var/www/repuve-backend-v1/public
- ./storage:/var/www/repuve-backend-v1/storage
- ./Docker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf - ./Docker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf
networks: networks:
- repuve-network - repuve-network

View File

@ -28,7 +28,7 @@
Route::middleware('auth:api')->group(function() { Route::middleware('auth:api')->group(function() {
// Rutas de inscripción de vehículos // Rutas de inscripción de vehículos
Route::post('inscripcion', [InscriptionController::class, 'vehicleInscription']); Route::post('inscripcion', [InscriptionController::class, 'vehicleInscription']);
Route::get('consulta', [InscriptionController::class, 'searchRecord']); Route::get('consultaV', [InscriptionController::class, 'searchRecord']);
// Rutas de expedientes y documentos // Rutas de expedientes y documentos
Route::get('expediente/{id}/pdf', [RecordController::class, 'generatePdf']); Route::get('expediente/{id}/pdf', [RecordController::class, 'generatePdf']);