#2 ✨ feat(associado): adicionar 'first_access_at' no retorno do usuário [#868kf2642]

Спојено
joycekepler споји(ла) 1 комит(е) из Softpar/feature/SERPRATI-JOY-868kf2642-alteracoes-associado у Softpar/development пре 6 дана
2 измењених фајлова са 4 додато и 1 уклоњено
  1. 3 0
      app/Http/Resources/UserResource.php
  2. 1 1
      app/Services/UserService.php

+ 3 - 0
app/Http/Resources/UserResource.php

@@ -38,6 +38,9 @@ class UserResource extends JsonResource
                                                 : null,
             'on_leave_at'                => $this->on_leave_at?->format('Y-m-d H:i:s'),
             'on_leave_by_user_id'        => $this->on_leave_by_user_id,
+            'first_access_at'            => $this->access_logs_min_accessed_at
+                                                ? Carbon::parse($this->access_logs_min_accessed_at)->format('Y-m-d H:i:s')
+                                                : null,
             'unread_notifications_count' => (int) ($this->unread_notifications_count ?? 0),
             'created_at'                 => Carbon::parse($this->created_at)->format('Y-m-d H:i:s'),
             'updated_at'                 => Carbon::parse($this->updated_at)->format('Y-m-d H:i:s'),

+ 1 - 1
app/Services/UserService.php

@@ -24,7 +24,7 @@ class UserService
 
     public function getAllPaginated(array $filters = [], int $perPage = 10): \Illuminate\Pagination\LengthAwarePaginator
     {
-        $query = User::with(['position', 'sector'])->orderBy('name', 'asc');
+        $query = User::with(['position', 'sector'])->withMin('accessLogs', 'accessed_at')->orderBy('name', 'asc');
 
         if (!empty($filters['type'])) {
             $query->where('type', $filters['type']);