summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Light <samlight1994@gmail.com>2025-03-28 01:08:28 +0000
committerSam Light <samlight1994@gmail.com>2025-03-28 01:08:28 +0000
commit9e1fd1ce9426b00fc87ce51e52a9296ca847bdd5 (patch)
treea0038e0dae3f38eafc895a946bbf20aa27a2fe87
parentc0a79fed865ca91eae26d95132be7bf1daaf5618 (diff)
Setup product relationship to category
-rw-r--r--workbench/app/Models/Product.php6
1 files changed, 6 insertions, 0 deletions
diff --git a/workbench/app/Models/Product.php b/workbench/app/Models/Product.php
index 11e88e5..1edb185 100644
--- a/workbench/app/Models/Product.php
+++ b/workbench/app/Models/Product.php
@@ -5,6 +5,7 @@ namespace Workbench\App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Product extends Model
{
@@ -23,4 +24,9 @@ class Product extends Model
->orWhere('description', 'like', $s)
));
}
+
+ public function category(): BelongsTo
+ {
+ return $this->belongsTo(Category::class);
+ }
}