Beispiel #1
0
 /**
  * @test
  */
 public function it_allows_create_a_image_with_gallery()
 {
     $file = new \Symfony\Component\HttpFoundation\File\UploadedFile($this->tempFile, 'regal.png');
     $fileSizeBefore = filesize($this->tempFile);
     // convert and save
     $image = new CreateImage($file, null, 'galleryFolder');
     $filepath = $image->handle();
     $this->assertEquals('/powerimage/galleryFolder/regal.png', $filepath);
     // file exists
     $this->assertTrue(Storage::disk('powerimage')->exists('/galleryFolder/regal.png'));
     // file is optimized
     $this->assertLessThan($fileSizeBefore, Storage::disk('powerimage')->size('/galleryFolder/regal.png'), 'Image optimization doesn\'t works');
 }
Beispiel #2
0
 /**
  * Updates a entry.
  *
  * @param $id
  * @param array $data
  *
  * @return bool|int
  */
 public function updateEntry($id, array $data)
 {
     $entry = $this->getEntry($id);
     if (!empty($data['file'])) {
         // update image
         $deleteImage = new DeleteImage($entry->filepath);
         $deleteImage->handle();
         $createImage = new CreateImage($data['file'], $data['filename'], 'gallery/');
         $data['filepath'] = $createImage->handle();
     }
     $status = $entry->update($data);
     return $status;
 }
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $image = new CreateImage($this->getUploadedFile(), $this->filename, $this->folder);
     return $image->handle();
 }