2015年3月6日 星期五

Add User Data for Testing using seeding (Lavarel 5)

1)  Edit "DatabaseSeeder.php" under  database/seeds in the project directory.

2) Uncomment the following line:

$this->call('UserTableSeeder');

3) Add the following block of code:

use App\User;

class UserTableSeeder extends Seeder {

    public function run()
    {
        DB::table('users')->delete();

        User::create(array(
                'name' => 'admin',
                'email' => 'admin@test.com',
                'password' => Hash::make('password')
            ));
    }
}


4)  Run the following command to add data to the user table.

 php artisan db:seed 

沒有留言: