コード例 #1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $monitors = Monitor::select('*')->selectRaw('DATE_ADD(pinged_at, INTERVAL allowed_runtime SECOND) as end_time')->where('state', Monitor::STATE_RUNNING)->having('end_time', '<', new Carbon())->get();
     /** @var Monitor $monitor */
     foreach ($monitors as $monitor) {
         $monitor->warnings()->create(['type' => Monitor::STATE_LATE]);
         $monitor->state = Monitor::STATE_LATE;
         $monitor->save();
     }
 }
コード例 #2
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     // Set UUID for Monitors on create
     Monitor::creating(function (Monitor $monitor) {
         $monitor->uuid = Uuid::generate(4);
     });
     \Blade::directive('datediff', function ($carbon) {
         return "<?php echo '<span title=\"'\n                .with{$carbon}->format('Y-m-d H:i:s').'\">'.with{$carbon}->diffForHumans().'</span>'; ?>";
     });
 }
コード例 #3
0
 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router  $router
  * @return void
  */
 public function boot(Router $router)
 {
     $router->bind('integrations', function ($id) use($router) {
         $user = \Auth::user();
         return Integration::whereUserId($user->id)->whereId($id)->firstOrFail();
     });
     $router->bind('monitors', function ($uuid) {
         return Monitor::where('uuid', $uuid)->firstOrFail();
     });
     parent::boot($router);
 }
コード例 #4
0
 /**
  * Remove the specified resource from storage.
  *
  * @param Monitor $monitor
  * @return \Illuminate\Http\Response
  * @internal param int $id
  */
 public function destroy(Monitor $monitor)
 {
     $monitor->delete();
     return redirect(route('account.monitors.index'));
 }
コード例 #5
0
 public function fail(Request $request, Monitor $monitor)
 {
     $monitor->updateState(Monitor::STATE_FAIL);
 }