Ejemplo n.º 1
0
 /**
  * Load the main report page.
  * 
  * @return string
  */
 public function index()
 {
     $fields = $this->_captureReportFields();
     $report_levels = ReportLevel::orderBy('id')->lists('name', 'id')->all();
     $report_types = ReportType::orderBy('id')->lists('name', 'id')->all();
     switch ($fields['report_level_id']) {
         case ReportLevel::SERVER_LEVEL:
             $items = Server::orderBy('name')->lists('name', 'id')->all();
             break;
         case ReportLevel::SITE_LEVEL:
             $items = Site::orderBy('name')->lists('name', 'id')->all();
             break;
         case ReportLevel::SERVICE_LEVEL:
             $items = Service::orderBy('name')->lists('name', 'id')->all();
             break;
         case ReportLevel::CLIENT_LEVEL:
         default:
             $items = Client::orderBy('name')->lists('name', 'id')->all();
             break;
     }
     return view('report.form', compact('fields', 'report_levels', 'report_types', 'items'));
 }
Ejemplo n.º 2
0
 public function run()
 {
     Server::truncate();
     $services = Service::lists('id')->all();
     $operating_systems = OperatingSystem::lists('id')->all();
     $database_technologies = DatabaseTechnology::lists('id')->all();
     foreach ($services as $service) {
         $limit = rand(2, 20);
         for ($i = 1; $i < $limit; $i++) {
             $sites = Site::where('service_id', $service)->lists('id')->all();
             $site = $sites[array_rand($sites, 1)];
             Server::create(['id' => "{$site}" . str_pad($i, 3, '0', STR_PAD_LEFT), 'name' => "Sample server {$i}", 'enabled' => rand(0, 1), 'description' => "Sample server {$i}", 'site_id' => "{$site}", 'operating_system_id' => array_rand($operating_systems, 1), 'database_technology_id' => array_rand($database_technologies, 1)]);
         }
     }
 }