From 9e1fd1ce9426b00fc87ce51e52a9296ca847bdd5 Mon Sep 17 00:00:00 2001 From: Sam Light Date: Fri, 28 Mar 2025 01:08:28 +0000 Subject: Setup product relationship to category --- workbench/app/Models/Product.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'workbench') 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); + } } -- cgit v1.2.3