Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

CategoryFactory.php 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. namespace Database\Factories;
  3. use App\Models\Setting\Category;
  4. use Illuminate\Database\Eloquent\Factories\Factory;
  5. /**
  6. * @extends Factory<Category>
  7. */
  8. class CategoryFactory extends Factory
  9. {
  10. /**
  11. * The name of the factory's corresponding model.
  12. *
  13. * @var string
  14. */
  15. protected $model = Category::class;
  16. /**
  17. * Define the model's default state.
  18. *
  19. * @return array<string, mixed>
  20. */
  21. public function definition(): array
  22. {
  23. return [
  24. 'color' => $this->faker->hexColor,
  25. ];
  26. }
  27. /**
  28. * Indicate that the category is of income type.
  29. *
  30. * @return Factory<Category>
  31. */
  32. public function income(): Factory
  33. {
  34. return $this->state(function (array $attributes) {
  35. return [
  36. 'type' => 'income',
  37. ];
  38. });
  39. }
  40. /**
  41. * Indicate that the category is of expense type.
  42. *
  43. * @return Factory<Category>
  44. */
  45. public function expense(): Factory
  46. {
  47. return $this->state(function (array $attributes) {
  48. return [
  49. 'type' => 'expense',
  50. ];
  51. });
  52. }
  53. }