public function getDownload($assetID)
 {
     $asset = \App\Models\Media::find($assetID);
     if (!$asset) {
         abort(404);
     }
     ob_clean();
     return response()->download($asset->filePath('o'));
 }
示例#2
0
 public function getRemove($id)
 {
     $media_model = \App\Models\Media::find($id);
     if (!$media_model) {
         return ['success' => false];
     }
     $media_model->delete();
     return ['success' => true];
 }
示例#3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $news = Media::find($id);
     foreach ($this->sizes as $value) {
         $f = public_path() . $news->filepath . $value . $news->filename;
         if (file_exists($f) && is_file($f)) {
             unlink($f);
         }
     }
     $news->delete();
     return Redirect::route('media.admin');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  *
  * @return Response
  */
 public function destroy($id)
 {
     $media = Media::find($id);
     $this->checkExist($media);
     $media->delete();
     return response()->return();
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int $id
  *
  * @return Response
  */
 public function destroy($id)
 {
     $media = Media::find($id);
     if (is_null($media)) {
         throw new NotFoundException();
     }
     $media->delete();
     return response()->return();
 }
 public function destroy($pk)
 {
     // Check if primary_key matching $pk exist
     if (!$this->rowExist($this->model, $pk)) {
         Flash::error(trans($this->trans_path . 'general.error.no-data-found'));
         return $this->redirectToRoute();
     }
     $productModel = $this->model;
     $productDataModel = $this->productBasketData;
     $productData = $productDataModel::where('product_id', $pk)->first();
     // Remove Main Product Image
     if ($productData->image) {
         parent::__unlinkFile($this->imagePath, $productData->image);
         parent::__unlinkFileThumbnails($this->thumbnail_dimensions, $this->imagePath, $productData->image);
     }
     // Remove Multiple Images for Product
     $imgs = ProductMedia::where('product_id', $pk)->get(['id', 'media_id']);
     foreach ($imgs as $img) {
         $mediaObj = Media::find($img->media_id);
         // Remove old image
         parent::__unlinkFile($this->imagePath, $mediaObj->media);
         parent::__unlinkFileThumbnails($this->imgGalleryThumbDimension, $this->imagePath, $mediaObj->media);
         // Remove Data Form Media Table
         // This will remove child ProductMedia Data
         $mediaObj->delete();
     }
     // Remove Product
     // Product Attribute Value and Media Data
     // will be removed automatically due to FKey relation
     $productModel::pk($pk)->delete();
     Flash::success(trans($this->trans_path . 'general.status.deleted'));
     return $this->redirectToRoute();
 }