/**
  * Removes the specified computer from the specified patch.
  *
  * @param int|string $patchId
  * @param int|string $computerId
  *
  * @return mixed
  */
 public function destroy($patchId, $computerId)
 {
     $patch = $this->patch->findOrFail($patchId);
     if ($patch->computers()->detach($computerId) === 1) {
         flash()->success('Success!', 'Successfully removed computer..');
         return redirect()->route('resources.patches.show', [$patch->id]);
     } else {
         flash()->error('Error!', 'There was an issue removing this computer from this patch. Please try again.');
         return redirect()->route('resources.patches.show', [$patch->id]);
     }
 }
示例#2
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;
 }
示例#3
0
 /**
  * Execute the job.
  *
  * @return bool
  */
 public function handle()
 {
     $this->patch->title = $this->request->input('title', $this->patch->title);
     $this->patch->description = $this->request->input('description', $this->patch->description);
     if ($this->patch->save()) {
         // Check if we have any files to upload and attach.
         if (count($this->request->files) > 0) {
             foreach ($this->request->file('files') as $file) {
                 if (!is_null($file)) {
                     $this->patch->uploadFile($file);
                 }
             }
         }
         return $this->patch;
     }
     return false;
 }
示例#4
0
 /**
  * Deletes the specified patch.
  *
  * @param int|string $id
  *
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $patch = $this->patch->findOrFail($id);
     if ($patch->delete()) {
         flash()->success('Success!', 'Successfully deleted patch.');
         return redirect()->route('resources.patches.index');
     } else {
         flash()->error('Error!', 'There was an issue deleting this patch. Please try again.');
         return redirect()->route('resources.patches.show', [$id]);
     }
 }
 /**
  * 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']);
             };
         });
     });
 }