1 개요

Laravel seeding

라라벨 Database Seeding라라벨 데이터베이스 시딩, 라라벨 시딩

2 예시

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