*/ public function toArray(Request $request): array { return [ 'id' => $this->id, 'nombre_apellido' => $this->nombre_apellido, 'dni' => $this->dni, 'email' => $this->email, 'rol_codigo' => $this->rol_codigo, 'role' => $this->whenLoaded('role', fn () => [ 'codigo' => $this->role?->codigo, 'nombre' => $this->role?->nombre, ]), 'categories' => $this->whenLoaded('scanCategories', fn () => $this->scanCategories ->map(fn ($category) => [ 'id' => $category->id, 'nombre' => $category->nombre, ])->values()), ]; } }