Esempio n. 1
0
 /**
  * Delete a client by ID
  * @param $id
  * @return mixed
  */
 public function destroy($id)
 {
     $property = $this->findById($id);
     $image_delete = $property->image;
     $property->delete();
     File::delete(dir_photos_path('properties') . $image_delete);
     File::delete(dir_photos_path('properties') . 'thumb_' . $image_delete);
     return $property;
 }
 /**
  * Delete a category by ID
  * @param $id
  * @return \Illuminate\Support\Collection|DbCategoryRepository|static
  */
 public function destroy($id)
 {
     $category = $this->findById($id);
     $image_delete = $category->image;
     $category->delete();
     File::delete(dir_photos_path('categories') . $image_delete);
     File::delete(dir_photos_path('categories') . 'thumb_' . $image_delete);
     return $category;
 }
Esempio n. 3
0
 /**
  * Delete a client by ID
  * @param $id
  * @return mixed
  */
 public function destroy($id)
 {
     $client = $this->findById($id);
     $image_delete = $client->image;
     $client->delete();
     File::delete(dir_photos_path('clients') . $image_delete);
     File::delete(dir_photos_path('clients') . 'thumb_' . $image_delete);
     return $client;
 }
 /**
  * Save the photo in the server
  * @param $file
  * @param $name
  * @param $directory
  * @param null $width
  * @param null $height
  * @param $thumbWidth
  * @param null $thumbHeight
  * @param null $watermark
  * @return string
  */
 public function storeImage($file, $name, $directory, $width = null, $height = null, $thumbWidth, $thumbHeight = null, $watermark = null)
 {
     $extension = pathinfo($file["name"], PATHINFO_EXTENSION);
     $filename = Str::slug($name) . '.' . $extension;
     $path = dir_photos_path($directory);
     $image = Image::make($file["tmp_name"]);
     File::exists($path) or File::makeDirectory($path, 0775, true);
     $image->interlace();
     // IF THE FILE SIZE IS BIGGER(1MB+) RESIZE
     if ($image->filesize() >= 1048576) {
         if ($width) {
             if ($image->width() > $image->height()) {
                 if ($image->width() >= $width) {
                     $image->resize($width, $height, function ($constraint) {
                         $constraint->aspectRatio();
                     });
                 } else {
                     $image->resize($image->width(), $height, function ($constraint) {
                         $constraint->aspectRatio();
                     });
                 }
             } else {
                 if ($image->height() >= $width) {
                     $image->resize($height, $width, function ($constraint) {
                         $constraint->aspectRatio();
                     });
                 } else {
                     $image->resize($image->height(), $width, function ($constraint) {
                         $constraint->aspectRatio();
                     });
                 }
             }
         }
     }
     if ($watermark) {
         $image->insert('img/logo.png', 'center');
     }
     $image->save($path . $filename, 60)->resize($thumbWidth, $thumbHeight, function ($constraint) {
         $constraint->aspectRatio();
     })->interlace()->save($path . 'thumb_' . $filename, 60);
     return $filename;
 }
 /**
  * Delete a product by ID
  * @param $id
  * @return mixed
  */
 public function destroy($id)
 {
     $product = $this->findById($id);
     $image_delete = $product->image;
     $photos_delete = $product->id;
     $product->delete();
     File::delete(dir_photos_path('products') . $image_delete);
     File::delete(dir_photos_path('products') . 'thumb_' . $image_delete);
     File::deleteDirectory(dir_photos_path('products') . $photos_delete);
     return $product;
 }