/** * Generate Outage Task Details scoped to Groups * @method generateOutageTaskDetailsScopedToGroups * @param Outage $outage [description] * @return [type] [description] */ private function generateOutageTaskDetailsScopedToGroups(Outage $outage) { $groups = $this->scope_to_groups->lists('id'); switch ($this->task_type) { case 'Server Task': $servers = \App\Server::active()->whereIn('group_id', $groups); if (!!$this->scope_to_operating_systems->count()) { $oses = $this->scope_to_operating_systems->lists('id'); $servers = $servers->whereIn('operating_system_id', $oses); } if ($this->scope_to_production_servers == 1) { $servers = $servers->production(); } elseif ($this->scope_to_production_servers == 2) { $servers = $servers->nonproduction(); } $servers = $servers->get(); return $this->generateOutageTaskDetailsScopedToServers($outage, $servers); case 'Application Task': $applications = \App\Application::active()->whereIn('group_id', $groups)->get(); return $this->generateOutageTaskDetailsScopedToApplications($outage, $applications); case 'Database Task': $databases = \App\Database::active()->whereIn('group_id', $groups)->get(); if ($this->scope_to_production_servers == 1) { $databases = $databases->production(); } elseif ($this->scope_to_production_servers == 2) { $databases = $databases->nonproduction(); } return $this->generateOutageTaskDetailsScopedToDatabases($outage, $databases); } }