Ejemplo n.º 1
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function deletefile($id)
 {
     //
     $paths = Config::get('uploads');
     $file = McFile::find($id);
     $product = ProductCategory::find(Input::get('product_category_id'));
     //$full = $filepath."/".$file->file_name;
     //echo $full;
     //Delete from Files Table
     $file->delete();
     //Delete from Files/Product Table
     $product->files()->where('file_id', '=', $id)->delete();
     //Delete Files
     foreach ($paths as $path) {
         $filepath = $path . "/" . $file->file_name;
         if (File::exists($filepath)) {
             File::delete($filepath);
             // echo "Deleted: ".$filepath."<br>";
         }
     }
     Session::flash('message', 'Successfully deleted files for ' . $product->title);
     return Redirect::to('admin/products/' . Input::get('product_category_id') . '/files');
 }
Ejemplo n.º 2
0
 public function detail($id, $productid)
 {
     //Get Cat
     $productcategory = ProductCategory::find($id);
     //Get SUbcats
     $product = ProductCategory::find($productid);
     $image = McFile::find($product->default_image);
     $file_categories = FileCategory::lists('file_category_name', 'id');
     $files = $product->files;
     $cats = array();
     foreach ($file_categories as $k => $cat) {
         foreach ($files as $file) {
             if ($k == $file->file_category) {
                 $tmp['file_title'] = $file->file_title;
                 $tmp['file_name'] = $file->file_name;
                 $cats[$cat][] = $tmp;
                 $tmp = '';
             }
         }
     }
     return View::make('productcategory.detail')->with('productsnav', $this->productsNav())->with('productcategory', $productcategory)->with('files', $cats)->with('image', $image)->with('product', $product);
     //Get Subcategories
 }