Пример #1
0
 public function run()
 {
     ProductInfomation::truncate();
     $template = 'app/views/admin/template.blade.php';
     $template = file_get_contents($template);
     for ($i = 1; $i <= 30; $i++) {
         ProductInfomation::create(array('name_product' => 'Product_' . $i, 'value' => $template, 'product_id' => $i));
     }
 }
Пример #2
0
 /**
  * [saveEditInfomation description]
  * @param  [type] $product_id   [description]
  * @param  [type] $content      [description]
  * @param  [type] $product_name [description]
  * @return [type]               [description]
  */
 public static function saveEditInfomation($product_id, $content, $product_name)
 {
     $update = ProductInfomation::whereProduct_id($product_id)->update(array('value' => $content, 'name_product' => $product_name));
     return;
 }
Пример #3
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);
 }