Develop an E-Commerce Website with Laravel 5.4 – Part 5 - luqman-kodaq
======
luqman-kodaq
Hi, thanks for your tutorials... but i'm not getting the expected result on my
side. I can't seed my shoeProductTableSeeder equivalent to your
ProductsTableSeeder. I'm getting an undefined offset:0. This is my code:

shoeProductsTableSeeder

{ $categories = ['Adult shoes', 'Corporate shoes', 'Baby shoes', 'Sport
shoes'];

    
    
                foreach ($categories as $category){
                # First fetch category Id            
    
              	$category          = DB::table('categories')->where('name', '=', trim(strtolower( $category )))->get();
            	$category_id       = $category[0]->id;
            	$actual_price      = rand(15000, 20000);
            	$discount_factor   = (10/100) * $actual_price; // 10% of actual price
            	$discount_price    = $actual_price - $discount_factor;
           
    
            	DB::table('shoeProducts')->insert([
            		'title'         => 'Product for ' . $category[0]->name,
            		'image'         => '../images/shoes8.jpg',
            		'category_id'   => $category_id,
            		'original_price'=> $actual_price,
            		'discount_price'=> $discount_price,
            		'in_stock'      => 1,
            		'status'        => 1,
            		'created_at'    => Carbon::now(),
            	]);
            }
    
        }
    

I'll appreciate an early reply... Thanks

