diff --git a/app/Http/Controllers/Repuve/InscriptionController.php b/app/Http/Controllers/Repuve/InscriptionController.php index bb7ab69..ea05cec 100644 --- a/app/Http/Controllers/Repuve/InscriptionController.php +++ b/app/Http/Controllers/Repuve/InscriptionController.php @@ -133,6 +133,7 @@ public function vehicleInscription(VehicleStoreRequest $request) 'folio' => $folio, 'vehicle_id' => $vehicle->id, 'user_id' => Auth::id(), + 'module_id' => Auth::user()->module_id, ]); // Procesar archivos diff --git a/app/Http/Controllers/Repuve/RecordController.php b/app/Http/Controllers/Repuve/RecordController.php index e6e0ad0..094179a 100644 --- a/app/Http/Controllers/Repuve/RecordController.php +++ b/app/Http/Controllers/Repuve/RecordController.php @@ -14,7 +14,7 @@ class RecordController extends Controller { public function generatePdf($id) { - $record = Record::with('vehicle')->findOrFail($id); + $record = Record::with('vehicle.owner', 'user', 'module')->findOrFail($id); $pdf = Pdf::loadView('pdfs.record', compact('record')) ->setPaper('a4', 'portrait') @@ -179,6 +179,47 @@ public function generatePdfImages($id) } } + public function generatePdfForm(Request $request) + { + $request->validate([ + 'fecha' => 'nullable|string', + 'mes' => 'nullable|string', + 'anio' => 'nullable|string', + 'marca' => 'required|string', + 'linea' => 'required|string', + 'modelo' => 'required|string', + 'niv' => 'required|string', + 'numero_motor' => 'required|string', + 'placa' => 'required|string', + 'folio' => 'required|string', + 'telefono' => 'nullable|string', + ]); + + $data = [ + 'fecha' => $request->input('fecha', ''), + 'mes' => $request->input('mes', ''), + 'anio' => $request->input('anio', ''), + 'marca' => $request->input('marca'), + 'linea' => $request->input('linea'), + 'modelo' => $request->input('modelo'), + 'niv' => $request->input('niv'), + 'numero_motor' => $request->input('numero_motor'), + 'placa' => $request->input('placa'), + 'folio' => $request->input('folio'), + 'telefono' => $request->input('telefono', ''), + ]; + + $pdf = Pdf::loadView('pdfs.form', $data) + ->setPaper('a4', 'portrait') + ->setOptions([ + 'defaultFont' => 'sans-serif', + 'isHtml5ParserEnabled' => true, + 'isRemoteEnabled' => true, + ]); + + return $pdf->stream('solicitud-sustitucion-' . time() . '.pdf'); + } + public function errors(Request $request) { $request->validate([ diff --git a/app/Models/Owner.php b/app/Models/Owner.php index e372750..c5bbfeb 100644 --- a/app/Models/Owner.php +++ b/app/Models/Owner.php @@ -27,6 +27,7 @@ class Owner extends Model 'num_int', 'colonia', 'cp', + 'telefono', ]; protected $appends = [ diff --git a/app/Models/Record.php b/app/Models/Record.php index 574f21b..416e981 100644 --- a/app/Models/Record.php +++ b/app/Models/Record.php @@ -13,6 +13,7 @@ class Record extends Model 'folio', 'vehicle_id', 'user_id', + 'module_id', 'error_id', 'api_response', 'error_occurred_at', @@ -42,4 +43,9 @@ public function error() { return $this->belongsTo(Error::class); } + + public function module() + { + return $this->belongsTo(Module::class); + } } diff --git a/database/migrations/2025_11_25_200950_add_module_id_to_records_table.php b/database/migrations/2025_11_25_200950_add_module_id_to_records_table.php new file mode 100644 index 0000000..887c7b1 --- /dev/null +++ b/database/migrations/2025_11_25_200950_add_module_id_to_records_table.php @@ -0,0 +1,33 @@ +foreignId('module_id') + ->nullable() + ->after('user_id') + ->constrained('modules') + ->nullOnDelete(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('records', function (Blueprint $table) { + $table->dropForeign(['module_id']); + $table->dropColumn('module_id'); + }); + } +}; diff --git a/database/migrations/2025_11_25_203741_add_telefono_to_owners_table.php b/database/migrations/2025_11_25_203741_add_telefono_to_owners_table.php new file mode 100644 index 0000000..b8f6447 --- /dev/null +++ b/database/migrations/2025_11_25_203741_add_telefono_to_owners_table.php @@ -0,0 +1,28 @@ +string('telefono')->nullable()->after('cp'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('owners', function (Blueprint $table) { + $table->dropColumn('telefono'); + }); + } +}; diff --git a/resources/views/pdfs/constancia.blade.php b/resources/views/pdfs/constancia.blade.php index 70e789b..573a093 100644 --- a/resources/views/pdfs/constancia.blade.php +++ b/resources/views/pdfs/constancia.blade.php @@ -6,174 +6,192 @@
|
+
+ |
+ + |
+ SEGURIDAD
+ SECRETARÍA DE SEGURIDAD Y PROTECCIÓN CIUDADANA + |
+
- VILLAHERMOSA, TAB - {{ now()->format('d') }} de - {{ ucfirst(now()->translatedFormat('F')) }} de - {{ now()->format('Y') }} -
+{{ $record->vehicle->owner->full_name }}
-Propietario
+PROPIETARIO
{{ $record->user->full_name }}
-Operador
+OPERADOR