public function getByProject($projectUuid) { // check for inactive or non-existant project // $project = Project::where('project_uid', '=', $projectUuid)->first(); if (!$project || !$project->isActive()) { return array(); } $assessmentResultsQuery = AssessmentResult::where('project_uid', '=', $projectUuid); // add filters // $assessmentResultsQuery = DateFilter::apply($assessmentResultsQuery); $assessmentResultsQuery = TripletFilter::apply($assessmentResultsQuery, $projectUuid); // order results before applying filter // $assessmentResultsQuery = $assessmentResultsQuery->orderBy('create_date', 'DESC'); // add limit filter // $assessmentResultsQuery = LimitFilter::apply($assessmentResultsQuery); // perform query // return $assessmentResultsQuery->get(); }
public function getQueryByProject($projectUuid) { if (!strpos($projectUuid, '+')) { // check for inactive or non-existant project // $project = Project::where('project_uid', '=', $projectUuid)->first(); if (!$project || !$project->isActive()) { return AssessmentRun::getQuery(); } // get by a single project // $assessmentRunsQuery = AssessmentRun::where('project_uuid', '=', $projectUuid); // add filters // $assessmentRunsQuery = TripletFilter::apply($assessmentRunsQuery, $projectUuid); } else { // get by multiple projects // $projectUuids = explode('+', $projectUuid); foreach ($projectUuids as $projectUuid) { // check for inactive or non-existant project // $project = Project::where('project_uid', '=', $projectUuid)->first(); if (!$project || !$project->isActive()) { continue; } if (!isset($assessmentRunsQuery)) { $assessmentRunsQuery = AssessmentRun::where('project_uuid', '=', $projectUuid); } else { $assessmentRunsQuery = $assessmentRunsQuery->orWhere('project_uuid', '=', $projectUuid); } // add filters // $assessmentRunsQuery = TripletFilter::apply($assessmentRunsQuery, $projectUuid); } } return $assessmentRunsQuery; }