Laravel Inserting data with a Model Factory


Example

You may wish to use Model Factories within your seeds. This will create 3 new users.

use App\Models\User;

class UserTableSeeder extends Illuminate\Database\Seeder{

    public function run(){
        factory(User::class)->times(3)->create();    
    }
}

You may also want to define specific fields on your seeding like a password, for instance. This will create 3 users with the same password.

factory(User::class)->times(3)->create(['password' => '123456']);