database/seeds/HotelTableSeeder.php
/**
     * Run the database seeds.
     *
     * @return void
     */
Run the database seeds.
@return void
Run the database seeds . @return void
public function run()
    {
        if (env('APP_ENV') != 'production') {
            $faker = Faker::create('id_ID');
            for ($i = 1; $i <= 5; $i++){
                KelasHotel::create([
                    'nama' => 'Bintang ' . $i,
                ]);
            }
            for ($i = 1; $i <= 20; $i++){
                Hotel::create([
                    'nama' => 'Test Hotel ' . $i,
                    'desc' => $faker->text,
                    'rating' => $faker->randomElement(['1', '2', '3', '4', '5']),
                    'lokasi' => $faker->address,
                ]);
            }
            for ($i = 1; $i <= 40; $i++) {
                Fasilitas::create([
                    'nama' => $faker->randomElement(['Swimming Pool' ,'Meeting Room', 'Ballroom', 'Dinning Room']),
                    'kategori' => 'Tempat',
                    'hotel_id' => rand(1,20),
                    'jumlah' => rand(1,5)
                ]);
                Fasilitas::create([
                    'nama' => $faker->randomElement(['Breakfast', 'Have Lunch', 'Afternoon Meal', 'Dinner']),
                    'kategori' => 'Makan',
                    'hotel_id' => rand(1,20),
                    'jumlah' => rand(1,5)
                ]);
            }
            User::create([
                'name' => 'Sandy Maulana',
                'avatar' => NULL,
                'username' => 'kuronekosan',
                'password' => '$2y$10$rYmUwh1EAw.6jDEhuY9Squclfppz6IstMnAWZUanqv/Y0WV3GoxAC',
            ]);
        } else {
            throw new BindingResolutionException("Application is in production launching! Seeding is disabled.");
        }
    }
public function run ( ) { if ( env ( 'APP_ENV' ) != 'production' ) { $ faker = Faker :: create ( 'id_ID' ) ; for ( $ i = 1 ; $ i <= 5 ; $ i ++ ) { KelasHotel :: create ( [ 'nama' => 'Bintang ' . $ i , ] ) ; } for ( $ i = 1 ; $ i <= 20 ; $ i ++ ) { Hotel :: create ( [ 'nama' => 'Test Hotel ' . $ i , 'desc' => $ faker -> text , 'rating' => $ faker -> randomElement ( [ '1' , '2' , '3' , '4' , '5' ] ) , 'lokasi' => $ faker -> address , ] ) ; } for ( $ i = 1 ; $ i <= 40 ; $ i ++ ) { Fasilitas :: create ( [ 'nama' => $ faker -> randomElement ( [ 'Swimming Pool' , 'Meeting Room' , 'Ballroom' , 'Dinning Room' ] ) , 'kategori' => 'Tempat' , 'hotel_id' => rand ( 1 , 20 ) , 'jumlah' => rand ( 1 , 5 ) ] ) ; Fasilitas :: create ( [ 'nama' => $ faker -> randomElement ( [ 'Breakfast' , 'Have Lunch' , 'Afternoon Meal' , 'Dinner' ] ) , 'kategori' => 'Makan' , 'hotel_id' => rand ( 1 , 20 ) , 'jumlah' => rand ( 1 , 5 ) ] ) ; } User :: create ( [ 'name' => 'Sandy Maulana' , 'avatar' => NULL , 'username' => 'kuronekosan' , 'password' => '$2y$10$rYmUwh1EAw.6jDEhuY9Squclfppz6IstMnAWZUanqv/Y0WV3GoxAC' , ] ) ; } else { throw new BindingResolutionException ( " Application is in production launching! Seeding is disabled. " ) ; } }
Run the database seeds.
Run the database seeds .
// $name = $faker->name;