My query mysql like this :
SELECT *
FROM categories a
JOIN categories b ON b.parent_id = a.id
JOIN products c ON c.category_id = b.id
WHERE a.id = 1
I want change it to laravel eloquent
On the model category, I try like this :
self::join('categories b', 'b.parent_id', '=', 'a.id')
->join('products c', 'c.category_id', '=', 'b.id')
->findWhere(['a.id','=',$id]);
I'm confused add alias to self
How can I do it?
Note :
I want to use self
. Not others
via samuel toh