您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

TaxFactory.php 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace Database\Factories\Setting;
  3. use App\Enums\{TaxComputation, TaxScope, TaxType};
  4. use App\Models\Setting\Tax;
  5. use Illuminate\Database\Eloquent\Factories\Factory;
  6. /**
  7. * @extends Factory<Tax>
  8. */
  9. class TaxFactory extends Factory
  10. {
  11. /**
  12. * The name of the factory's corresponding model.
  13. */
  14. protected $model = Tax::class;
  15. /**
  16. * Define the model's default state.
  17. *
  18. * @return array<string, mixed>
  19. */
  20. public function definition(): array
  21. {
  22. return [
  23. 'description' => $this->faker->sentence,
  24. 'rate' => $this->faker->randomFloat(4, 0, 20),
  25. 'computation' => $this->faker->randomElement(TaxComputation::class),
  26. 'scope' => $this->faker->randomElement(TaxScope::class),
  27. 'enabled' => true,
  28. ];
  29. }
  30. public function salesTax(): self
  31. {
  32. return $this->state([
  33. 'name' => 'State Sales Tax',
  34. 'type' => TaxType::Sales,
  35. ]);
  36. }
  37. public function purchaseTax(): self
  38. {
  39. return $this->state([
  40. 'name' => 'State Purchase Tax',
  41. 'type' => TaxType::Purchase,
  42. ]);
  43. }
  44. }