*/ public function toArray(Request $request): array { return [ 'id' => $this->id, 'name' => $this->name, 'code' => $this->code, 'description' => $this->description, 'status' => $this->status, 'created_by' => $this->created_by, 'owner' => $this->owner, 'address' => $this->address, 'group_id' => $this->group_id ?? 0, 'geo_address_code' => $this->geo_address_code, 'acl' => $this->acl, 'whitelist' => $this->whitelist, 'latitude' => $this->latitude, 'longitude' => $this->longitude, 'parent_id' => $this->parent_id, 'level' => count(explode(",", trim($this->path, ","))), 'children' => $this->when($this->children->isNotEmpty(), function () { return $this->children->map(function ($child) { return new AssetResource($child, $this->level); })->all(); }), ]; } }