Version: Next 🚧
Factories (are a short name for Model Factories).
Factories are used to generate some fake data with the help of Faker to be used for testing purposes.
Factories are mainly used from Tests.
- Factories SHOULD be created in the Containers.
- All Factories MUST extend from
class UserFactory extends Factory
protected $model = User::class;
public function definition(): array
'name' => $this->faker->name,
'email' => $this->faker->unique()->safeEmail,
'password' => $password ?: $password = Hash::make('testing-password'),
'email_verified_at' => now(),
'remember_token' => Str::random(10),
'is_admin' => false,
// creating 4 users
More info at Laravel Docs.