AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Plan.php 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. /**
  5. * One pricing plan and what it allows. The price is in sen (1 ringgit = 100 sen).
  6. *
  7. * @property int $id
  8. * @property string $key
  9. * @property string $name
  10. * @property int $price
  11. * @property int $stores
  12. * @property int $regenerations
  13. * @property int $edits
  14. * @property string $period
  15. * @property string|null $stripe_product_id
  16. * @property string|null $stripe_price_id
  17. * @property int $sort
  18. */
  19. class Plan extends Model
  20. {
  21. public static function findByKey(string $key): ?self
  22. {
  23. return static::query()->where('key', $key)->first();
  24. }
  25. public function isPaid(): bool
  26. {
  27. return $this->price > 0;
  28. }
  29. /**
  30. * What the dashboard is allowed to see. The price is in ringgit here.
  31. *
  32. * @return array<string, mixed>
  33. */
  34. public function toDisplay(): array
  35. {
  36. return [
  37. 'key' => $this->key,
  38. 'name' => $this->name,
  39. 'price' => $this->price / 100,
  40. 'stores' => $this->stores,
  41. 'regenerations' => $this->regenerations,
  42. 'edits' => $this->edits,
  43. 'period' => $this->period,
  44. ];
  45. }
  46. /**
  47. * @return array<string, string>
  48. */
  49. protected function casts(): array
  50. {
  51. return [
  52. 'price' => 'integer',
  53. 'stores' => 'integer',
  54. 'regenerations' => 'integer',
  55. 'edits' => 'integer',
  56. 'sort' => 'integer',
  57. ];
  58. }
  59. }