function makeCriteriaProject($values) { $estimates = array(); foreach ($values as $value) { $project_estimates = Estimate::getMany(array('project' => $value)); if (!empty($project_estimates)) { $estimates = array_merge($estimates, $project_estimates); } } return $this->makeCriteriaEstimate(array_map(function ($item) { return $item->id; }, $estimates)); }