Requirement::query()->whereIn('asset_id',$this->child_id)->count(), 'plan_total' => $this->plans()->count(), 'prject_total' => $this->projects()->count(), 'plan_unexpired_total' => $planTotalCount = $this->plans()->where('begin', '<=', $now) ->where('end', '>=', $now) ->get() ->count(), 'project_unexpired_total' => $planTotalCount = $this->projects()->where('begin', '<=', $now) ->where('end', '>=', $now) ->get() ->count(), 'asset_total'=>Asset::query()->where('company_id',Auth::user()->company_id)->where('parent_id',0)->count(), 'asset_closed_total'=>Asset::query()->where('company_id',Auth::user()->company_id)->where('parent_id',0)->where('status','closed')->count(), '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, 'geo_address_code' => $this->geo_address_code, 'acl' => $this->acl, 'whitelist' => $this->whitelist, 'latitude' => $this->latitude, 'longitude' => $this->longitude, 'parent_id' => $this->parent_id, 'created_at' => $this->created_at, ]; } }