Преглед изворни кода

ajuste data expiracao carteirinha associado

Gustavo Zanatta пре 1 месец
родитељ
комит
821e3610c9
1 измењених фајлова са 6 додато и 1 уклоњено
  1. 6 1
      app/Services/AssociadoImportService.php

+ 6 - 1
app/Services/AssociadoImportService.php

@@ -19,7 +19,8 @@ class AssociadoImportService
         Excel::import($import, $filePath);
         $rows = $import->rows ?? collect();
 
-        $today = Carbon::today()->toDateString();
+        $today      = Carbon::today()->toDateString();
+        $expiryDate = Carbon::now()->endOfMonth()->toDateString();
 
         $existing = User::where('type', UserTypeEnum::ASSOCIADO)
             ->whereNotNull('registration')
@@ -57,6 +58,9 @@ class AssociadoImportService
                     $changed = true;
                 }
 
+                $user->expiry_date = $expiryDate;
+                $changed = true;
+
                 if ($changed) {
                     $user->save();
                     $updated++;
@@ -74,6 +78,7 @@ class AssociadoImportService
                     'status'         => UserStatusEnum::ACTIVE,
                     'registration'   => $registration,
                     'admission_date' => $today,
+                    'expiry_date'    => $expiryDate,
                 ]);
 
                 $created++;