Ejemplo n.º 1
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     ProductImage::create(['title' => 'Product 3 - image title', 'url' => 'zamkniecie-kasetowe-do-skrzynek-narzedziowych-k-o.jpg', 'product_id' => 3, 'published' => 1, 'main' => 1]);
     ProductImage::create(['title' => 'Product 4 - image title', 'url' => 'zawias-do-burt-aluminiowych.jpg', 'product_id' => 4, 'published' => 1, 'main' => 1]);
     ProductImage::create(['title' => 'Product 5 - image title', 'url' => 'zawias-drzwi-bocznych-k-o-l-155-kpl.jpg', 'product_id' => 5, 'published' => 1, 'main' => 1]);
 }
 /**
  * Fungsi untuk menyimpan gambar produk
  * @param  Request $request [description]
  * @return [type]           [description]
  */
 public function store(Request $request)
 {
     $this->validate($request, ['product_id' => 'required|exists:products,id', 'base64_image' => 'required']);
     $product_id = $request->get('product_id');
     $base64_image = $request->file('base64_image');
     $image_product = $this->saveImage($product_id, $base64_image);
     $image_product = ProductImage::create($image_product);
     return $image_product;
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create();
     ProductImage::truncate();
     //For each product we will be inserting random number of keywords
     foreach (range(1, 50) as $product_index) {
         $num_entries = rand(0, 3);
         $i = 1;
         foreach (range(0, $num_entries) as $entries) {
             ProductImage::create(['product_id' => $product_index, 'image_path' => 'image_' . $i . '.jpeg']);
             $i++;
         }
     }
 }