|
|
@@ -4,6 +4,8 @@ namespace App\Http\Livewire\Traits;
|
|
|
|
|
|
use App\Models\ReportDataPartiCoinvolte;
|
|
|
use App\Models\ReportDataVeicoli;
|
|
|
+use Illuminate\Support\Facades\Log;
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
trait HasAnagrafica{
|
|
|
public $currentAnagrafica;
|
|
|
@@ -289,14 +291,9 @@ trait HasAnagrafica{
|
|
|
|
|
|
public function anagraficaDataParteComuneSave(){
|
|
|
// Start a database transaction to ensure data consistency
|
|
|
- \DB::beginTransaction();
|
|
|
+ DB::beginTransaction();
|
|
|
|
|
|
try {
|
|
|
- // Log current vehicle value for debugging
|
|
|
- \Log::info('Current vehicle value: ' . $this->currentVeicolo);
|
|
|
- \Log::info('Current progressive: ' . $this->currentProgressive);
|
|
|
- \Log::info('Current report ID: ' . $this->dataId);
|
|
|
-
|
|
|
// Update ReportDataVeicoli instead of delete/create
|
|
|
$veicolo = ReportDataVeicoli::updateOrCreate(
|
|
|
[
|
|
|
@@ -495,13 +492,12 @@ trait HasAnagrafica{
|
|
|
]);
|
|
|
|
|
|
// If we reach here, all operations succeeded
|
|
|
- \DB::commit();
|
|
|
+ DB::commit();
|
|
|
session()->flash('success', 'Record aggiornato');
|
|
|
|
|
|
} catch (\Exception $ex) {
|
|
|
- // If any operation failed, roll back the transaction
|
|
|
- \DB::rollBack();
|
|
|
- \Log::error('Error in anagraficaDataParteComuneSave: ' . $ex->getMessage());
|
|
|
+ DB::rollBack();
|
|
|
+ Log::error('Error in anagraficaDataParteComuneSave: ' . $ex->getMessage());
|
|
|
session()->flash('error', 'Errore in fase di aggiornamento (' . $ex->getMessage() . ')');
|
|
|
}
|
|
|
|