Пример #1
0
 /**
  * Execute the job.
  *
  * @return GuideStep|bool
  */
 public function handle()
 {
     $this->step->title = $this->request->input('title', $this->step->title);
     $this->step->description = $this->request->input('description', $this->step->description);
     if ($this->step->save()) {
         // If saving the step is successful, we'll process the file upload if there is one.
         $file = $this->request->file('image');
         if ($file instanceof UploadedFile) {
             $this->step->deleteFiles();
             $this->step->uploadFile($file, $path = null, $resize = true);
         }
         return $this->step;
     }
     return false;
 }
Пример #2
0
 /**
  * Persist the changes.
  *
  * @param Guide     $guide
  * @param GuideStep $step
  *
  * @return GuideStep|bool
  */
 public function persist(Guide $guide, GuideStep $step)
 {
     $step->guide_id = $guide->id;
     $step->title = $this->input('title');
     $step->description = $this->input('description');
     if ($step->save()) {
         // Retrieve the image for the step.
         $file = $this->file('image');
         if ($file instanceof UploadedFile) {
             $step->deleteFiles();
             $step->uploadFile($file, $path = null, $resize = true);
         }
         // No image was uploaded, we'll return the step.
         return $step;
     }
     return false;
 }