database/seeders/DatabaseSeeder.php
/**
     * Seed the application's database.
     *
     * @return void
     */
Seed the application's database.
@return void
Seed the application ' s database . @return void
public function run()
    {
        $this->call(UserSeeder::class);
        $this->call(CouponSeeder::class);
        $this->call(CategorySeeder::class);
        $this->call(ProductSeeder::class);
        Product::each(function($product) {
            $product
                ->categories()
                ->sync([
                    FactoryHelper::getRandomModelId(Category::class),
                    FactoryHelper::getRandomModelId(Category::class)
                ]);
        });
    }
public function run ( ) { $ this -> call ( UserSeeder :: class ) ; $ this -> call ( CouponSeeder :: class ) ; $ this -> call ( CategorySeeder :: class ) ; $ this -> call ( ProductSeeder :: class ) ; Product :: each ( function ( $ product ) { $ product -> categories ( ) -> sync ( [ FactoryHelper :: getRandomModelId ( Category :: class ) , FactoryHelper :: getRandomModelId ( Category :: class ) ] ) ; } ) ; }
Seed the application's database.
Seed the application ' s database .