protected function seedTestData() { $faker = Faker::create(); $store = Driver::create(array('email' => $faker->email, 'password' => \Hash::make($faker->name), 'photo' => $faker->imageUrl(250, 250), 'name' => $faker->name, 'seller_id' => $faker->firstName, 'address' => array('street' => $faker->streetAddress, 'city' => $faker->city, 'country' => $faker->country, 'postcode' => $faker->postcode), 'currency' => 'USD')); Category::create(array('name' => 'food', 'description' => $faker->text(), 'status' => 1)); Product::create(array('name' => $faker->name, 'driver_id' => $store->id, 'description' => $faker->text(), 'photos' => $faker->imageUrl(250, 250), 'tax_amount' => $faker->randomFloat(2, 0, 2), 'unit_price' => $faker->randomFloat(1, 2, 10), 'category_id' => 1, 'inventory' => 0, 'average_cost' => 0)); }
public function run() { /** * Truncate Product Tables before seed faker data */ DB::table('products')->truncate(); DB::table('product_costs')->truncate(); $faker = Faker::create(); for ($i = 0; $i < 10; $i++) { $product = Product::create(array('name' => $faker->name, 'driver_id' => $faker->numberBetween(1, 10), 'description' => $faker->text(), 'photos' => array(array('order' => 1, 'url' => $faker->imageUrl(250, 250))), 'tax_amount' => 0.02 + $i * 0.001, 'unit_price' => $faker->randomFloat(1, 2, 10), 'category_id' => $faker->numberBetween(1, 3), 'inventory' => 0, 'average_cost' => 0)); for ($j = 0; $j < 5; $j++) { Cost::create(array('unit_cost' => (5 + $j) / 2, 'inventory' => 10, 'product_id' => $product->id)); } } }