After 12 years working with the United Nations, I shifted my career to programming at the end of 2017. I now work on tech-for-good projects and help teach programming to disavantaged groups.
you paginate. where you do $categories = Category::whereNull('parent_id')->with('childs')->get(); you can do $categories = Category::whereNull('parent_id')->with('childs')->paginate(x); where x is the number of items you want to show on page.
how do you limit the numbers of categories(total of both parent and child) to show on the page?
you paginate. where you do
$categories = Category::whereNull('parent_id')->with('childs')->get();
you can do$categories = Category::whereNull('parent_id')->with('childs')->paginate(x);
where x is the number of items you want to show on page.that will do pagination based on the count of the
parent_id
category.I wanted to display the categories with a hierarchy. Ended up with this:
that will do pagination based on the count of the
parent_id
category.I wanted to display the categories with a hierarchy. Ended up with this: