Quantcast
Channel: Php recursive method getting products - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by alagu for Php recursive method getting products

$
0
0

In Laravel,

hasMany() and belongsTo() creates Parent & Child Categories relationship.

Simply use in Model that extends Eloquent. For sample,

    public function getChildValues() {        return $this->hasMany('Category', 'parentid');    }         public function getParentValues() {        return $this->belongsTo('CategoryMN', 'id');    } 

This link might help you.

And to retrieve for example, in Controller,

$categories_child = Category::with('getChildValues')->get(); 

Viewing all articles
Browse latest Browse all 2




<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>