Ejemplo n.º 1
0
 /**
  * Stores the ticket and returns to the server status page.
  * 
  * @return void
  */
 public function store(TicketRequest $request)
 {
     $ticket = Ticket::create(['server_check_result_id' => $request->get('server_check_result_id'), 'raised_at' => Carbon::now(), 'reference' => $request->get('reference'), 'ticket_category_id' => $request->get('ticket_category_id'), 'ticket_priority_id' => $request->get('ticket_priority_id'), 'ticket_type_id' => $request->get('ticket_type_id'), 'summary' => $request->get('summary'), 'description' => $request->get('description')]);
     $server_check_result = ServerCheckResult::find($request->get('server_check_result_id'));
     $server_check_result->ticket_id = $ticket->id;
     $server_check_result->save();
     foreach ($server_check_result->serverCheckResults as $child) {
         $child->ticket_id = $ticket->id;
         $child->save();
     }
     return redirect('status/server/' . $request->get('server_id'));
 }
Ejemplo n.º 2
0
 /**
  * Randomly creates server check results for test purposes.
  * 
  * @param type $healthchecks
  * @return void
  */
 public function run($healthchecks = 1000)
 {
     ServerCheckResult::truncate();
     $faker = \Faker\Factory::create();
     $servers = Server::lists('id')->all();
     $check_results = CheckResult::lists('id')->all();
     for ($i = 0; $i < $healthchecks; $i++) {
         $check_result = $faker->randomElement($check_results);
         $date = date("H-m-d H:i:s");
         DB::unprepared("CALL sp_new_server_check_result('" . "{$faker->randomElement($servers)}', " . "'{$check_result}', " . "'{$date}')");
         sleep(1);
     }
 }