Esempio n. 1
0
 /**
  * Catches and runs operations when a computer is deleted.
  *
  * @param Computer $computer
  */
 public function deleting(Computer $computer)
 {
     if (!$computer->deleted_at) {
         $statuses = $computer->statuses()->get();
         foreach ($statuses as $status) {
             $status->delete();
         }
     }
 }
Esempio n. 2
0
 /**
  * Returns a calendar chart of the graph of the specified computer's statuses.
  *
  * @param Computer $computer
  *
  * @return mixed
  */
 public function graphOfStatus(Computer $computer)
 {
     $statuses = $computer->statuses()->thisMonth()->get();
     $dataTable = Lava::DataTable();
     $dataTable->addDateColumn('Date')->addNumberColumn('Status');
     foreach ($statuses as $status) {
         $dataTable->addRow([$status->created_at, $status->online]);
     }
     return Lava::LineChart('Status')->setOptions(['title' => "{$computer->name} Status This Month Over Time", 'datatable' => $dataTable, 'legend' => (new Legend())->position('bottom'), 'vAxis' => (new VerticalAxis())->title('Offline / Online')]);
 }