diff --git a/src/Models/Category.php b/src/Models/Category.php index 4bfdf933..8341c9ed 100644 --- a/src/Models/Category.php +++ b/src/Models/Category.php @@ -9,6 +9,7 @@ use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsToMany; use Illuminate\Database\Eloquent\SoftDeletes; @@ -61,6 +62,14 @@ public function getMorphClass(): string return static::getProxiedClass(); } + /** + * Get the parent for the category. + */ + public function parent(): BelongsTo + { + return $this->belongsTo(static::class, 'parent_id'); + } + /** * Get the products for the category. */