diff options
author | Sam Light <samlight1994@gmail.com> | 2025-03-28 01:08:28 +0000 |
---|---|---|
committer | Sam Light <samlight1994@gmail.com> | 2025-03-28 01:08:28 +0000 |
commit | 9e1fd1ce9426b00fc87ce51e52a9296ca847bdd5 (patch) | |
tree | a0038e0dae3f38eafc895a946bbf20aa27a2fe87 | |
parent | c0a79fed865ca91eae26d95132be7bf1daaf5618 (diff) |
Setup product relationship to category
-rw-r--r-- | workbench/app/Models/Product.php | 6 |
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); + } } |