database/seeders/UsersTableSeeder.php
/**
     * Run the database seeds.
     *
     * @return void
     */
Run the database seeds.
@return void
Run the database seeds . @return void
public function run()
    {
        User::factory()->count(10)->create();
        $user = User::find(1);
        $user->name = 'lizhixin';
        $user->email = '173612205@qq.com';
        $user->avatar = 'https://cdn.learnku.com/uploads/images/201710/14/1/ZqM7iaP4CR.png';
        $user->password = bcrypt('12345678');
        $user->assignRole('Founder');
        $user->save();
        $user = User::find(2);
        $user->name = 'zhixin';
        $user->email = 'tftlig@sina.com';
        $user->avatar = 'https://cdn.learnku.com/uploads/images/201710/14/1/ZqM7iaP4CR.png';
        $user->password = bcrypt('12345678');
        $user->assignRole('Maintainer');
        $user->save();
        $user = User::find(3);
        $user->name = 'ceshihao';
        $user->email = 'pian266@126.com';
        $user->avatar = 'https://cdn.learnku.com/uploads/images/201710/14/1/ZqM7iaP4CR.png';
        $user->password = bcrypt('12345678');
        $user->save();
    }
public function run ( ) { User :: factory ( ) -> count ( 10 ) -> create ( ) ; $ user = User :: find ( 1 ) ; $ user -> name = 'lizhixin' ; $ user -> email = '173612205@qq.com' ; $ user -> avatar = 'https://cdn.learnku.com/uploads/images/201710/14/1/ZqM7iaP4CR.png' ; $ user -> password = bcrypt ( '12345678' ) ; $ user -> assignRole ( 'Founder' ) ; $ user -> save ( ) ; $ user = User :: find ( 2 ) ; $ user -> name = 'zhixin' ; $ user -> email = 'tftlig@sina.com' ; $ user -> avatar = 'https://cdn.learnku.com/uploads/images/201710/14/1/ZqM7iaP4CR.png' ; $ user -> password = bcrypt ( '12345678' ) ; $ user -> assignRole ( 'Maintainer' ) ; $ user -> save ( ) ; $ user = User :: find ( 3 ) ; $ user -> name = 'ceshihao' ; $ user -> email = 'pian266@126.com' ; $ user -> avatar = 'https://cdn.learnku.com/uploads/images/201710/14/1/ZqM7iaP4CR.png' ; $ user -> password = bcrypt ( '12345678' ) ; $ user -> save ( ) ; }
Run the database seeds.
Run the database seeds .
// 生成数据集合 // 单独处理第一个用户的数据