original_string: private function cropPhoto($cropper, $dataRow)
      {
          $folder = $this->folder;
          $disk = Storage::disk($this->filesystem);
  
          //If a folder is not exists, then make the folder
          if (!$disk->exists($folder)) {
              $disk->makeDirectory($folder);
          }
  
          $itemId = $this->model->id;
  
          foreach ($cropper as $cropParam) {
              $inputName = $dataRow->field.'_'.$cropParam->name;
              $params = json_decode($this->request->get($inputName));
  
              if (!is_object($params)) {
                  return false;
              }
  
              $imageName = $this->request->{$dataRow->field};
              $image = Image::make($disk->path($imageName));
  
              $image->crop(
                  (int) $params->w,
                  (int) $params->h,
                  (int) $params->x,
                  (int) $params->y
              );
  
              $image->resize($cropParam->size->width, $cropParam->size->height);
              $photoName = $folder.'/'.$inputName.'_'.$itemId.'_'.$cropParam->size->name.'.'.$image->extension;
  
              if (isset($cropParam->watermark) && file_exists($cropParam->watermark)) {
                  $watermark = Image::make(public_path() . '/' . $cropParam->watermark);
                  $watermark->resize($cropParam->size->width, null);
                  $image->insert($watermark);
              }
  
              $image->save($disk->path($photoName), $this->quality);
  
              if (!empty($cropParam->resize)) {
                  foreach ($cropParam->resize as $cropParamResize) {
                      $image->resize($cropParamResize->width, $cropParamResize->height, function ($constraint) {
                          $constraint->aspectRatio();
                      });
  
                      $photoName = $folder.'/'.$inputName.'_'.$itemId.'_'.$cropParamResize->name.'.'.$image->extension;
                      $image->save($disk->path($photoName), $this->quality);
                  }
              }
  
              $this->model->{$dataRow->field} = $imageName;
              $this->model->save();
          }
      }
code: private function cropPhoto($cropper, $dataRow)
      {
          $folder = $this->folder;
          $disk = Storage::disk($this->filesystem);
  
          //If a folder is not exists, then make the folder
          if (!$disk->exists($folder)) {
              $disk->makeDirectory($folder);
          }
  
          $itemId = $this->model->id;
  
          foreach ($cropper as $cropParam) {
              $inputName = $dataRow->field.'_'.$cropParam->name;
              $params = json_decode($this->request->get($inputName));
  
              if (!is_object($params)) {
                  return false;
              }
  
              $imageName = $this->request->{$dataRow->field};
              $image = Image::make($disk->path($imageName));
  
              $image->crop(
                  (int) $params->w,
                  (int) $params->h,
                  (int) $params->x,
                  (int) $params->y
              );
  
              $image->resize($cropParam->size->width, $cropParam->size->height);
              $photoName = $folder.'/'.$inputName.'_'.$itemId.'_'.$cropParam->size->name.'.'.$image->extension;
  
              if (isset($cropParam->watermark) && file_exists($cropParam->watermark)) {
                  $watermark = Image::make(public_path() . '/' . $cropParam->watermark);
                  $watermark->resize($cropParam->size->width, null);
                  $image->insert($watermark);
              }
  
              $image->save($disk->path($photoName), $this->quality);
  
              if (!empty($cropParam->resize)) {
                  foreach ($cropParam->resize as $cropParamResize) {
                      $image->resize($cropParamResize->width, $cropParamResize->height, function ($constraint) {
                          $constraint->aspectRatio();
                      });
  
                      $photoName = $folder.'/'.$inputName.'_'.$itemId.'_'.$cropParamResize->name.'.'.$image->extension;
                      $image->save($disk->path($photoName), $this->quality);
                  }
              }
  
              $this->model->{$dataRow->field} = $imageName;
              $this->model->save();
          }
      }
code_tokens: private function cropPhoto ( $ cropper , $ dataRow ) { $ folder = $ this -> folder ; $ disk = Storage :: disk ( $ this -> filesystem ) ; //If a folder is not exists, then make the folder if ( ! $ disk -> exists ( $ folder ) ) { $ disk -> makeDirectory ( $ folder ) ; } $ itemId = $ this -> model -> id ; foreach ( $ cropper as $ cropParam ) { $ inputName = $ dataRow -> field . '_' . $ cropParam -> name ; $ params = json_decode ( $ this -> request -> get ( $ inputName ) ) ; if ( ! is_object ( $ params ) ) { return false ; } $ imageName = $ this -> request -> { $ dataRow -> field } ; $ image = Image :: make ( $ disk -> path ( $ imageName ) ) ; $ image -> crop ( ( int ) $ params -> w , ( int ) $ params -> h , ( int ) $ params -> x , ( int ) $ params -> y ) ; $ image -> resize ( $ cropParam -> size -> width , $ cropParam -> size -> height ) ; $ photoName = $ folder . '/' . $ inputName . '_' . $ itemId . '_' . $ cropParam -> size -> name . '.' . $ image -> extension ; if ( isset ( $ cropParam -> watermark ) && file_exists ( $ cropParam -> watermark ) ) { $ watermark = Image :: make ( public_path ( ) . '/' . $ cropParam -> watermark ) ; $ watermark -> resize ( $ cropParam -> size -> width , null ) ; $ image -> insert ( $ watermark ) ; } $ image -> save ( $ disk -> path ( $ photoName ) , $ this -> quality ) ; if ( ! empty ( $ cropParam -> resize ) ) { foreach ( $ cropParam -> resize as $ cropParamResize ) { $ image -> resize ( $ cropParamResize -> width , $ cropParamResize -> height , function ( $ constraint ) { $ constraint -> aspectRatio ( ) ; } ) ; $ photoName = $ folder . '/' . $ inputName . '_' . $ itemId . '_' . $ cropParamResize -> name . '.' . $ image -> extension ; $ image -> save ( $ disk -> path ( $ photoName ) , $ this -> quality ) ; } } $ this -> model -> { $ dataRow -> field } = $ imageName ; $ this -> model -> save ( ) ; } }
docstring: Crop photo by coordinates.
  
  @param array                                   $cropper
  @param Illuminate\Database\Eloquent\Collection $dataRow
  
  @return void
docstring_tokens: Crop photo by coordinates .