Example #1
0
 /**
  * [infoEditProduct description]
  * @param  [type] $slug [description]
  * @return [type]       [description]
  */
 public function saveEditProduct($slug)
 {
     $edit_product = Input::all();
     unset($edit_product['hidden_description']);
     unset($edit_product['hidden_content']);
     $data['content_header'] = "Edit Infomation";
     $destinationPath = 'lib/images/products/';
     if (Input::hasFile('image')) {
         $this->deleteImage(Input::get('hidden_image'), $destinationPath . 'default-product.jpg');
         $this->deleteImage(Input::get('hidden_image_small'), $destinationPath . 'default-small.jpg');
         $filename = "product_" . Str::slug(Input::get('name')) . "." . Input::file('image')->getClientOriginalExtension();
         $filename_small = "product_" . Str::slug(Input::get('name')) . "_small." . Input::file('image')->getClientOriginalExtension();
         Input::file('image')->move($destinationPath, $filename);
         $img = $destinationPath . $filename;
         $img_small = $destinationPath . $filename_small;
         $image = new ResizeImages($img);
         $image->resizeImage(73, 73, 'exact');
         $image->saveImage($img_small, 100);
     } else {
         unset($edit_product['image']);
         $img = null;
     }
     Product::saveProduct($edit_product, $img, $img_small);
     ProductInfomation::saveEditInfomation(Input::get('hidden_product_id'), Input::get('info'), Input::get('name'));
     Session::flash('success', 'Edit thành công !');
     return Redirect::to('admin/product/' . $slug);
 }