summaryrefslogtreecommitdiff
path: root/workbench/app/Models/Order.php
diff options
context:
space:
mode:
authorSam Light <samlight1994@gmail.com>2026-02-10 00:21:10 +0000
committerSam Light <samlight1994@gmail.com>2026-02-10 00:21:10 +0000
commitad1c06ee1819b3512e2443d5cbe06199a0ae9bad (patch)
treeb873596f86173c70c29decc301397d716ad7ca8d /workbench/app/Models/Order.php
parent47c3c4b4e772c30dac12169300e20346fa47b71f (diff)
Created order tables and models
Diffstat (limited to 'workbench/app/Models/Order.php')
-rw-r--r--workbench/app/Models/Order.php51
1 files changed, 51 insertions, 0 deletions
diff --git a/workbench/app/Models/Order.php b/workbench/app/Models/Order.php
new file mode 100644
index 0000000..84a13ab
--- /dev/null
+++ b/workbench/app/Models/Order.php
@@ -0,0 +1,51 @@
+<?php
+
+namespace Workbench\App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+use Illuminate\Database\Eloquent\Relations\BelongsToMany;
+use Illuminate\Support\Carbon;
+use Workbench\App\Enums\OrderStatus;
+use Workbench\Database\Factories\OrderFactory;
+
+/**
+ * @property int $id
+ * @property OrderStatus $status
+ * @property string $total
+ * @property Carbon|null $created_at
+ * @property Carbon|null $updated_at
+ */
+class Order extends Model
+{
+ /**
+ * @use HasFactory<OrderFactory>
+ */
+ use HasFactory;
+
+ /**
+ * @return OrderFactory<static>
+ */
+ protected static function newFactory(): OrderFactory
+ {
+ return OrderFactory::new();
+ }
+
+ /**
+ * @return array<string, string>
+ */
+ protected function casts(): array
+ {
+ return [
+ 'status' => OrderStatus::class,
+ ];
+ }
+
+ /**
+ * @return BelongsToMany<Product, $this>
+ */
+ public function products(): BelongsToMany
+ {
+ return $this->belongsToMany(Product::class)->withPivot('quantity', 'price')->withTimestamps();
+ }
+}