Exemple #1
0
 /**
  * Execute the job.
  *
  * @return bool
  */
 public function handle()
 {
     $computers = $this->request->input('computers');
     if (is_array($computers)) {
         foreach ($computers as $computer) {
             // Make sure the computer isn't already attached.
             if (!$this->patch->computers()->find($computer)) {
                 // Attach the computer to the patch.
                 $this->patch->computers()->attach($computer, ['patched_at' => new Carbon($this->request->input('patched'))]);
             }
         }
         return true;
     }
     return false;
 }
 /**
  * Returns a new table of all computers
  * that contain the specified patch.
  *
  * @param Patch $patch
  *
  * @return \Orchestra\Contracts\Html\Builder
  */
 public function table(Patch $patch)
 {
     $computers = $patch->computers();
     return $this->table->of('patches.computers', function (TableGrid $table) use($patch, $computers) {
         $table->with($computers);
         $table->column('name', function (Column $column) {
             $column->value = function (Computer $computer) {
                 return link_to_route('computers.show', $computer->name, [$computer->id]);
             };
         });
         $table->column('patched', function (Column $column) {
             $column->value = function (Computer $computer) {
                 return (new Carbon($computer->patched_at))->diffForHumans();
             };
         });
         $table->column('remove', function (Column $column) use($patch) {
             $column->value = function (Computer $computer) use($patch) {
                 $params = [$patch->id, $computer->id];
                 return link_to_route('resources.patches.computers.destroy', 'Remove', $params, ['data-post' => 'DELETE', 'data-title' => 'Are you Sure?', 'data-message' => 'Are you sure you want to remove this patch from this computer?', 'class' => 'btn btn-xs btn-danger']);
             };
         });
     });
 }