UserFactory.php 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Database\Factories;
  3. use Illuminate\Database\Eloquent\Factories\Factory;
  4. use Illuminate\Support\Str;
  5. /**
  6. * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\User>
  7. */
  8. class UserFactory extends Factory
  9. {
  10. /**
  11. * Define the model's default state.
  12. *
  13. * @return array<string, mixed>
  14. */
  15. public function definition()
  16. {
  17. return [
  18. 'name' => $this->faker->name(),
  19. 'phone' => $this->faker->phoneNumber(),
  20. 'email' => $this->faker->unique()->safeEmail(),
  21. 'email_verified_at' => now(),
  22. 'password' => bcrypt('12345678'),
  23. 'gender_id' => random_int(1, 2),
  24. 'role_id' => random_int(2, 4),
  25. 'outlet_id' => 1,
  26. 'remember_token' => Str::random(10),
  27. ];
  28. }
  29. /**
  30. * Indicate that the model's email address should be unverified.
  31. *
  32. * @return static
  33. */
  34. public function unverified()
  35. {
  36. return $this->state(function (array $attributes) {
  37. return [
  38. 'email_verified_at' => null,
  39. ];
  40. });
  41. }
  42. }