You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TaxFactory.php 1.2KB

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