Laravel seeding
라라벨 Database Seeding라라벨 데이터베이스 시딩, 라라벨 시딩
database/seeds
에 저장됨php artisan make:seeder UsersTableSeeder
→ plain seeder 가 생성됨
<?php
use Illuminate\\Database\\Seeder;
class UserTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//
}
}
<?php
use Illuminate\\Database\\Seeder;
use Illuminate\\Database\\Eloquent\\Model;
class UsersTableSeeder extends Seeder
{
public function run()
{
DB::table('users')->insert([
'name' => str_random(10),
'email' => str_random(10).'@example.com',
'password' => bcrypt('secret'),
]);
}
}
php artisan db:seed --class=UsersTableSeeder