original_string: public static function upload($file)
      {
          $photo = self::create();
  
          $image_manager = new ImageManager(['driver' => 'imagick']);
  
          $disk = Storage::disk(config('mustard.storage.disk', 'local'));
  
          if (!file_exists($file)) {
              RuntimeException("File $file does not exist");
          }
  
          $dest_dir = config('mustard.storage.photo.dir', 'mustard/photos');
          $quality = config('mustard.storage.photo.quality', 90);
  
          $disk->makeDirectory($dest_dir);
  
          $photo_id = $photo->getKey();
  
          Queue::push(function ($job) use ($file, $quality, $dest_dir, $photo_id) {
              if (!file_exists($file)) {
                  RuntimeException("File $file no longer exists");
              }
  
              $image_manager = new ImageManager(['driver' => 'imagick']);
  
              $disk = Storage::disk(config('mustard.storage.disk', 'local'));
  
              if ($file != "$dest_dir/$photo_id.jpg") {
                  $image = $image_manager->make($file);
  
                  $disk->put("$dest_dir/$photo_id.jpg", (string) $image->encode('jpg', $quality));
  
                  $image->destroy();
              }
  
              $image = $image_manager->make($file)->heighten(83);
  
              $disk->put("$dest_dir/{$photo_id}_s.jpg", (string) $image->encode('jpg', $quality));
  
              $image->destroy();
  
              $image = $image_manager->make($file)->widen(500);
  
              $disk->put("$dest_dir/{$photo_id}_l.jpg", (string) $image->encode('jpg', $quality));
  
              $image->destroy();
  
              $photo = Photo::find($photo_id);
  
              $photo->processed = true;
  
              $photo->save();
  
              $job->delete();
          });
  
          return $photo;
      }
code: public static function upload($file)
      {
          $photo = self::create();
  
          $image_manager = new ImageManager(['driver' => 'imagick']);
  
          $disk = Storage::disk(config('mustard.storage.disk', 'local'));
  
          if (!file_exists($file)) {
              RuntimeException("File $file does not exist");
          }
  
          $dest_dir = config('mustard.storage.photo.dir', 'mustard/photos');
          $quality = config('mustard.storage.photo.quality', 90);
  
          $disk->makeDirectory($dest_dir);
  
          $photo_id = $photo->getKey();
  
          Queue::push(function ($job) use ($file, $quality, $dest_dir, $photo_id) {
              if (!file_exists($file)) {
                  RuntimeException("File $file no longer exists");
              }
  
              $image_manager = new ImageManager(['driver' => 'imagick']);
  
              $disk = Storage::disk(config('mustard.storage.disk', 'local'));
  
              if ($file != "$dest_dir/$photo_id.jpg") {
                  $image = $image_manager->make($file);
  
                  $disk->put("$dest_dir/$photo_id.jpg", (string) $image->encode('jpg', $quality));
  
                  $image->destroy();
              }
  
              $image = $image_manager->make($file)->heighten(83);
  
              $disk->put("$dest_dir/{$photo_id}_s.jpg", (string) $image->encode('jpg', $quality));
  
              $image->destroy();
  
              $image = $image_manager->make($file)->widen(500);
  
              $disk->put("$dest_dir/{$photo_id}_l.jpg", (string) $image->encode('jpg', $quality));
  
              $image->destroy();
  
              $photo = Photo::find($photo_id);
  
              $photo->processed = true;
  
              $photo->save();
  
              $job->delete();
          });
  
          return $photo;
      }
code_tokens: public static function upload ( $ file ) { $ photo = self :: create ( ) ; $ image_manager = new ImageManager ( [ 'driver' => 'imagick' ] ) ; $ disk = Storage :: disk ( config ( 'mustard.storage.disk' , 'local' ) ) ; if ( ! file_exists ( $ file ) ) { RuntimeException ( "File $file does not exist" ) ; } $ dest_dir = config ( 'mustard.storage.photo.dir' , 'mustard/photos' ) ; $ quality = config ( 'mustard.storage.photo.quality' , 90 ) ; $ disk -> makeDirectory ( $ dest_dir ) ; $ photo_id = $ photo -> getKey ( ) ; Queue :: push ( function ( $ job ) use ( $ file , $ quality , $ dest_dir , $ photo_id ) { if ( ! file_exists ( $ file ) ) { RuntimeException ( "File $file no longer exists" ) ; } $ image_manager = new ImageManager ( [ 'driver' => 'imagick' ] ) ; $ disk = Storage :: disk ( config ( 'mustard.storage.disk' , 'local' ) ) ; if ( $ file != "$dest_dir/$photo_id.jpg" ) { $ image = $ image_manager -> make ( $ file ) ; $ disk -> put ( "$dest_dir/$photo_id.jpg" , ( string ) $ image -> encode ( 'jpg' , $ quality ) ) ; $ image -> destroy ( ) ; } $ image = $ image_manager -> make ( $ file ) -> heighten ( 83 ) ; $ disk -> put ( "$dest_dir/{$photo_id}_s.jpg" , ( string ) $ image -> encode ( 'jpg' , $ quality ) ) ; $ image -> destroy ( ) ; $ image = $ image_manager -> make ( $ file ) -> widen ( 500 ) ; $ disk -> put ( "$dest_dir/{$photo_id}_l.jpg" , ( string ) $ image -> encode ( 'jpg' , $ quality ) ) ; $ image -> destroy ( ) ; $ photo = Photo :: find ( $ photo_id ) ; $ photo -> processed = true ; $ photo -> save ( ) ; $ job -> delete ( ) ; } ) ; return $ photo ; }
docstring: Process a photo and create a record.
  
  @param string $file
  
  @return self
docstring_tokens: Process a photo and create a record .