Level 53
Described nicely here http://laravel.com/docs/5.0/eloquent#eager-loading
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi friends I am new to laravel 5, I need your help to show three level tree view category look like this
Laptop & Computers > //if clicked than show categories groups in dropdown <li>
------------------
Laptops
Computers > //if clicked than show sub categories dropdown <li>
---------
Dell
HP
---
Here is all the details may help......
1 - Tables Schema
categories
id - integer
name - string
subcatgroups
id - integer
name - string
cat_id- integer // foreign key for categories id
subcats
id - integer
name - string
sub_gid- integer // foreign key for subcatgroups id
thank God issue has been resolved :)
class Category extends Eloquent {
protected $appends = ['subcat']; // only available in Laravel 5
public function getSubcatAttribute() {
return $this->subcatgroup->subcat;
}
}
Please or to participate in this conversation.