$this->uuid, 'db_id' => $this->id, 'full_name' => $this->full_name, 'email' => $this->email, 'phone' => $this->phone, 'first_name' => $this->first_name, 'middle_name' => $this->middle_name, 'last_name' => $this->last_name, 'role' => $this->role, 'status' => $this->status, 'preferred_language' => $this->preferred_language, 'email_verified_at' => $this->email_verified_at?->toIso8601String(), 'phone_verified_at' => $this->phone_verified_at?->toIso8601String(), 'last_login_at' => $this->last_login_at?->toIso8601String(), 'tenant' => $this->relationLoaded('tenant') && $this->tenant ? [ 'id' => $this->tenant->uuid, 'name' => $this->tenant->name, 'code' => $this->tenant->code, 'boundary_polygon' => $this->tenant->boundary_polygon ? (function ($poly) { $rings = $poly->getGeometries(); $ring = $rings->first(); return $ring ? $ring->getGeometries()->map(fn ($p) => ['lat' => $p->latitude, 'lng' => $p->longitude])->all() : null; })($this->tenant->boundary_polygon) : null, ] : null, 'truck' => $this->role === User::ROLE_DRIVER && $this->relationLoaded('driverTeam') && $this->driverTeam?->truck ? new TruckResource($this->driverTeam->truck) : null, ]; } }