database/seeds/ProductsTableSeeder.php
/**
     * Run the database seeds.
     *
     * @return void
     */
Run the database seeds.
@return void
Run the database seeds . @return void
public function run()
    {
        Product::truncate();
        $faker = Faker::create('id_ID');
        for ($i=0; $i < 500; $i++) {
            $category = Category::find(rand(1,3));
            Product::create([
                'category_id' => $category->id,
                'sku' => 'ACHT-' . ($i + 1),
                'name' => $category->name . ' ' . $faker->name,
                'price' => rand(10000, 30000),
                'size_id' => rand(1,51),
                'qty' => rand(3,10),
                'description' => $faker->paragraph
            ]);
        }
    }
public function run ( ) { Product :: truncate ( ) ; $ faker = Faker :: create ( 'id_ID' ) ; for ( $ i = 0 ; $ i < 500 ; $ i ++ ) { $ category = Category :: find ( rand ( 1 , 3 ) ) ; Product :: create ( [ 'category_id' => $ category -> id , 'sku' => 'ACHT-' . ( $ i + 1 ) , 'name' => $ category -> name . ' ' . $ faker -> name , 'price' => rand ( 10000 , 30000 ) , 'size_id' => rand ( 1 , 51 ) , 'qty' => rand ( 3 , 10 ) , 'description' => $ faker -> paragraph ] ) ; } }
Run the database seeds.
Run the database seeds .