AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

OrderItem.php 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace App\Models;
  3. use Illuminate\Database\Eloquent\Attributes\Fillable;
  4. use Illuminate\Database\Eloquent\Model;
  5. use Illuminate\Database\Eloquent\Relations\BelongsTo;
  6. /**
  7. * One line of an order: a product, its price at the time, and how many.
  8. *
  9. * @property int $id
  10. * @property int $store_id
  11. * @property int $order_id
  12. * @property int|null $product_id
  13. * @property int|null $variant_id
  14. * @property string|null $variant_name
  15. * @property list<array{product_id: int, variant_id: int|null, quantity: int, label: string}>|null $bundle_contents For a bundle: what was inside, per bundle bought.
  16. * @property string $name
  17. * @property int $unit_price
  18. * @property int $quantity
  19. * @property int $line_total
  20. */
  21. #[Fillable(['store_id', 'product_id', 'variant_id', 'name', 'variant_name', 'bundle_contents', 'unit_price', 'quantity', 'line_total'])]
  22. class OrderItem extends Model
  23. {
  24. /**
  25. * @return BelongsTo<Order, $this>
  26. */
  27. public function order(): BelongsTo
  28. {
  29. return $this->belongsTo(Order::class);
  30. }
  31. /**
  32. * @return array<string, string>
  33. */
  34. protected function casts(): array
  35. {
  36. return [
  37. 'bundle_contents' => 'array',
  38. ];
  39. }
  40. }