Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

how can we manage category and product in laravek

public function parent() {
    return $this->belongsTo(Category::class, 'parent_id');
}

public function childs() {
    return $this->hasMany(Category::class, 'parent_id');
}

public function products() {
    return $this->hasManyThrough(Product::class, Category::class, 'parent_id', 'category_id', 'id');
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #manage #category #product #laravek
ADD COMMENT
Topic
Name
8+9 =