Esempio n. 1
0
 public function store()
 {
     $data = Input::all();
     try {
         $p = new Product();
         $p->name = Input::get('name');
         $p->description = Input::get('description');
         $p->price = Input::get('price');
         $p->active = 1;
         $p->manufacturer_id = Input::get('manufacturer');
         $p->rating = Input::get('rating');
         $p->stock = Input::get('stock');
         $p->created_at = time();
         $p->updated_at = time();
         $p->slug = Str::slug($p->name);
         $p->save();
         $images = array_filter(explode('###', Input::get('images')));
         foreach ($images as $image) {
             $img = new ProductImgs();
             $img->product_id = $p->id;
             $img->url = $image;
             $img->created_at = time();
             $img->updated_at = time();
             $img->save();
         }
     } catch (Exception $e) {
         print_r($e->getMessage());
         $this->code = 400;
     }
     Response::json([], $this->code);
 }
Esempio n. 2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     ProductImgs::create(['product_id' => Product::whereName('IMac')->first()->id, 'url' => 'http://ecx.images-amazon.com/images/I/91bGcrFfMOL._SL1500_.jpg', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     ProductImgs::create(['product_id' => Product::whereName('IMac')->first()->id, 'url' => 'http://ecx.images-amazon.com/images/I/81P-zJIjwVL._SL1500_.jpg', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     ProductImgs::create(['product_id' => Product::whereName('IPod')->first()->id, 'url' => 'http://ecx.images-amazon.com/images/I/51lwfofiMtL._SL1500_.jpg', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     ProductImgs::create(['product_id' => Product::whereName('IPod')->first()->id, 'url' => 'http://ecx.images-amazon.com/images/I/31JQYzM%2BoIL.jpg', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     ProductImgs::create(['product_id' => Product::whereName('Altavoces')->first()->id, 'url' => 'http://ecx.images-amazon.com/images/I/81f-UewGdoL._SL1345_.jpg', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     ProductImgs::create(['product_id' => Product::whereName('Altavoces')->first()->id, 'url' => 'http://ecx.images-amazon.com/images/I/81hLlCkUJ5L._SL1350_.jpg', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     ProductImgs::create(['product_id' => Product::whereName('Altavoces')->first()->id, 'url' => 'http://ecx.images-amazon.com/images/I/71tn5Oo7%2BWL._SL1350_.jpg', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     ProductImgs::create(['product_id' => Product::whereName('Altavoces')->first()->id, 'url' => 'http://ecx.images-amazon.com/images/I/51b6Kh2QxwL._SL1350_.jpg', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     ProductImgs::create(['product_id' => Product::whereName('Altavoces')->first()->id, 'url' => 'http://ecx.images-amazon.com/images/I/71hZ4jWonwL._SL1350_.jpg', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     ProductImgs::create(['product_id' => Product::whereName('Altavoces')->first()->id, 'url' => 'http://ecx.images-amazon.com/images/I/61LGy79iROL._SL1350_.jpg', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     ProductImgs::create(['product_id' => Product::whereName(utf8_encode('Cascos inalámbricos'))->first()->id, 'url' => 'http://ecx.images-amazon.com/images/I/71QqZFwjb%2BL._SL1500_.jpg', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     ProductImgs::create(['product_id' => Product::whereName(utf8_encode('Cascos inalámbricos'))->first()->id, 'url' => 'http://ecx.images-amazon.com/images/I/71oFokAf3TL._SL1500_.jpg', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     ProductImgs::create(['product_id' => Product::whereName('HP Z Display Z27i IPS')->first()->id, 'url' => 'http://ecx.images-amazon.com/images/I/31xpwABoPML.jpg', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     ProductImgs::create(['product_id' => Product::whereName('HP Z Display Z27i IPS')->first()->id, 'url' => 'http://ecx.images-amazon.com/images/I/31KXiTyXvUL.jpg', 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
 }