| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
-
- namespace App\Models;
-
- use Illuminate\Database\Eloquent\Attributes\Fillable;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Database\Eloquent\Relations\BelongsTo;
-
- /**
- * One line of an order: a product, its price at the time, and how many.
- *
- * @property int $id
- * @property int $store_id
- * @property int $order_id
- * @property int|null $product_id
- * @property int|null $variant_id
- * @property string|null $variant_name
- * @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.
- * @property string $name
- * @property int $unit_price
- * @property int $quantity
- * @property int $line_total
- */
- #[Fillable(['store_id', 'product_id', 'variant_id', 'name', 'variant_name', 'bundle_contents', 'unit_price', 'quantity', 'line_total'])]
- class OrderItem extends Model
- {
- /**
- * @return BelongsTo<Order, $this>
- */
- public function order(): BelongsTo
- {
- return $this->belongsTo(Order::class);
- }
-
- /**
- * @return array<string, string>
- */
- protected function casts(): array
- {
- return [
- 'bundle_contents' => 'array',
- ];
- }
- }
|