Jelajahi Sumber

feat: :sparkles: feat(carteirinha dependente) Foi adicionado a opção de data de validade e expiração

Foi adicionado a data de validade da carteirinha e tambem o status para o dependente

fase:dev | origin:escopo
kayo henrique 2 minggu lalu
induk
melakukan
a03903e078

+ 8 - 5
app/Http/Resources/AssociateValidationResource.php

@@ -17,16 +17,19 @@ class AssociateValidationResource extends JsonResource
             'cpf'          => $this->cpf,
             'registration' => $this->registration,
             'photo_url'    => $this->photo_path
-                                ? Storage::disk('s3')->temporaryUrl($this->photo_path, now()->addHours(24))
-                                : null,
+                ? Storage::disk('s3')->temporaryUrl($this->photo_path, now()->addHours(24))
+                : null,
             'expiry_date'  => $this->expiry_date?->format('d/m/Y'),
 
             'dependents' => $this->dependents->map(function ($dependent) {
                 return [
-                    'name'    => $dependent->name,
-                    'kinship' => $dependent->kinship,
+                    'id'          => $dependent->id,
+                    'name'        => $dependent->name,
+                    'kinship'     => $dependent->kinship,
+                    'status'      => $dependent->status,
+                    'expiry_date' => $this->expiry_date?->format('d/m/Y'),
                 ];
             })->values(),
         ];
     }
-}
+}

+ 7 - 8
app/Http/Resources/UserResource.php

@@ -38,14 +38,13 @@ class UserResource extends JsonResource
                 ? Storage::disk('s3')->temporaryUrl($this->photo_path, now()->addHours(24))
                 : null,
 
-            'dependents' => $this->whenLoaded('dependents', function () {
-                return $this->dependents->map(function ($dependent) {
-                    return [
-                        'name' => $dependent->name,
-                        'kinship' => $dependent->kinship,
-                    ];
-                })->values();
-            }),
+            'dependents' => $this->dependents->map(fn($dependent) => [
+                'id' => $dependent->id,
+                'name' => $dependent->name,
+                'kinship' => $dependent->kinship,
+                'status' => $dependent->status,
+                'expiry_date' => $this->expiry_date?->format('d/m/Y'),
+            ]),
             'first_access_completed_at'  => $this->first_access_completed_at?->format('Y-m-d H:i:s'),
             'terms_accepted_at'          => $this->terms_accepted_at?->format('Y-m-d H:i:s'),
             'on_leave_at'                => $this->on_leave_at?->format('Y-m-d H:i:s'),

+ 1 - 9
app/Services/UserService.php

@@ -24,15 +24,7 @@ class UserService
             $user->loadMissing('partnerAgreement');
         }
 
-        return $user->load([
-            'position',
-            'sector',
-            'dependents' => function ($query) {
-                $query->where('status', 'approved');
-            },
-        ])->loadCount([
-            'notificationSends as unread_notifications_count' => fn($q) => $q->where('read', false),
-        ]);
+        return $user->load(['position', 'sector', 'dependents',])->loadCount(['notificationSends as unread_notifications_count' => fn($q) => $q->where('read', false),]);
     }
 
     public function getAll(): Collection