FooFactory.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace Database\Factories;
  3. use App\Models\fkTest;
  4. use Illuminate\Database\Eloquent\Factories\Factory;
  5. /**
  6. * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\foo>
  7. */
  8. class FooFactory 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. 'email' => $this->faker->unique()->safeEmail(),
  20. 'email_verified_at' => now(),
  21. 'fk_tests_id' => $this->faker->randomElement(fkTest::pluck('id')),
  22. ];
  23. }
  24. /**
  25. * Indicate that the model's email address should be unverified.
  26. *
  27. * @return static
  28. */
  29. public function unverified()
  30. {
  31. return $this->state(function (array $attributes) {
  32. return [
  33. 'email_verified_at' => null,
  34. ];
  35. });
  36. }
  37. public function allOransheep()
  38. {
  39. return $this->state(function (array $attributes) {
  40. return [
  41. 'name' => 'oransheep',
  42. ];
  43. });
  44. }
  45. }