コード例 #1
0
ファイル: CheckController.php プロジェクト: dbirchak/ping
 public function store()
 {
     $input = Input::all();
     $validator = Validator::make($input, $this->rules);
     if ($validator->passes()) {
         $company = Company::forUser(Sentry::getUser()->id)->findOrFail($input['company_id']);
         $check = Check::create(array('company_id' => $company->id, 'user_id' => Sentry::getUser()->id, 'url' => $input['url'], 'port' => $input['port'], 'username' => !empty($input['username']) ? $input['username'] : null, 'password' => !empty($input['password']) ? $input['password'] : null, 'check_for' => !empty($input['check_for']) ? $input['check_for'] : null, 'interval' => $input['interval'], 'notify_failed_checks' => isset($input['notify_failed_checks']) ? true : false, 'notify_back_online' => isset($input['notify_back_online']) ? true : false, 'latency_satisfied' => $input['latency_satisfied'], 'latency_tolerating' => $input['latency_tolerating']));
         Session::flash('success', trans('check.create.success', array('url' => $check->url)));
         return Redirect::route('check.show', array('id' => $check->id));
     }
     return Redirect::back()->withErrors($validator)->withInput($input);
 }
コード例 #2
0
ファイル: CheckSeeder.php プロジェクト: dbirchak/ping
 /**
  * Run the user seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('checks')->delete();
     $check = Check::create(array('url' => 'http://www.example.com', 'user_id' => 1, 'company_id' => 1, 'port' => 80, 'interval' => 5));
     $start = \Carbon\Carbon::now()->subDays(3);
     $now = \Carbon\Carbon::now();
     while ($start->diffInSeconds($now, false) > 0) {
         $success = rand(0, 100) != 0;
         CheckResult::create(array('check_id' => $check->id, 'status_code' => $success ? 200 : 500, 'latency' => $success ? rand(100, 4000) : rand(10000, 60000), 'success' => $success, 'created_at' => $start));
         $start->addMinutes(5);
     }
     $check = Check::create(array('url' => 'http://www.example.org', 'user_id' => 2, 'company_id' => 2, 'port' => 8080, 'interval' => 15));
     $start = \Carbon\Carbon::now()->subDays(1);
     $now = \Carbon\Carbon::now();
     while ($start->diffInSeconds($now, false) > 0) {
         $success = rand(0, 100) != 0;
         CheckResult::create(array('check_id' => $check->id, 'status_code' => $success ? 200 : 500, 'latency' => $success ? rand(100, 4000) : rand(10000, 60000), 'success' => $success, 'created_at' => $start));
         $start->addMinutes(15);
     }
 }