$ php artisan make:seeder UserSeeder
Otomatis dibuatkan file UserSeeder.php ada di file database seeder
use Illuminate\Support\Str;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Faker\Factory as Faker;
$faker = Faker::create('id_ID');
for($i = 1; $i <= 50; $i++){
DB::table('users')->insert([
'name' => $faker->name,
'email' => $faker->email.'@gmail.com',
'password' => Hash::make('password'),
]);
}
$ php artisan db:seed --class=UserSeeder
$ php artisan migrate:fresh --seed
Komentar