Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,195,585 members, 7,958,814 topics. Date: Thursday, 26 September 2024 at 02:41 AM |
Nairaland Forum / Science/Technology / Programming / Create A Nested Lists Of Categories In Laravel 5 (10121 Views)
How To Create Multiple User Authentication In Laravel 5.3 / Common Error In Laravel #1:solved File_put_contents Failed To Open Stream / Solution To Tokenmismatchexception Problem In Laravel 5.1 (2) (3) (4)
Create A Nested Lists Of Categories In Laravel 5 by maekhel(m): 12:06am On Aug 26, 2015 |
Laravel gurus I need your help on a project am currently working on. Am trying to create a tree-like categories structure where each child will be listed under its parent. Am being able to create and save these categories in the database but now am finding it difficult to loop through the categories and display them. I want the categories to be rendered as below: Fashion Accessories - Bags - Cloths Mobile Phones - Tablets - Smartphones |
Re: Create A Nested Lists Of Categories In Laravel 5 by babatope88(m): 8:16am On Aug 26, 2015 |
Maybe this will work nested for each. give the sample of the data structure, this will aid more contribution from our nairaland e-family
|
Re: Create A Nested Lists Of Categories In Laravel 5 by danvery2k6(m): 8:47am On Aug 26, 2015 |
I presume you are using the blade templating engine. And that you also have categories and items tables linked together by foreign keys and the relationships properly defined in your models. |
Re: Create A Nested Lists Of Categories In Laravel 5 by maekhel(m): 9:41am On Aug 26, 2015 |
Sorry for not providing codes before. My Controller: public function index() My Category Model : <?phpMy View: <table class="table table-bordered table-hover">Yes I have a categories table with the following structure:
|
Re: Create A Nested Lists Of Categories In Laravel 5 by jacob05(m): 10:47am On Aug 26, 2015 |
Make things simple for yourself... it won't hurt creating another Model for CategoryItem Category
CategoryItem
Migratations
The Above Might not run but should explain the logic 1 Like |
Re: Create A Nested Lists Of Categories In Laravel 5 by Nobody: 12:38pm On Aug 26, 2015 |
check out adjacency model - http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/ - dhtml18 |
Re: Create A Nested Lists Of Categories In Laravel 5 by jacob05(m): 12:55pm On Aug 26, 2015 |
MuhammaduBuhari:Egbon, that one na sql wahala.... He's looking for the Laravel 5 approach |
Re: Create A Nested Lists Of Categories In Laravel 5 by Nobody: 2:09pm On Aug 26, 2015 |
Me no get time to dey read full posts o jare. No time to check time, am outa here. - troll |
Re: Create A Nested Lists Of Categories In Laravel 5 by jacob05(m): 2:14pm On Aug 26, 2015 |
MuhammaduBuhari: lol... Ok |
Re: Create A Nested Lists Of Categories In Laravel 5 by chiwex(m): 9:20pm On Aug 26, 2015 |
use Baum laravel package I always us it for unlimited category |
Re: Create A Nested Lists Of Categories In Laravel 5 by jacob05(m): 9:45pm On Aug 26, 2015 |
chiwex: An Over-Kill, to me, for the simple task... Baum\Node? , phewww |
Re: Create A Nested Lists Of Categories In Laravel 5 by chiwex(m): 10:02pm On Aug 26, 2015 |
baum is easy you can CREATE ADD UPDATE DELETED MOVE UP AND DOWN UR CATEGORIES without steers remember after implementing the package using a controller you can reuse it for any project |
Re: Create A Nested Lists Of Categories In Laravel 5 by jacob05(m): 10:13pm On Aug 26, 2015 |
chiwex: and those can't be done implementing "vanilla" Eloquent .... |
Re: Create A Nested Lists Of Categories In Laravel 5 by maekhel(m): 10:15pm On Aug 26, 2015 |
jacob05:Thats my take on Baum too. have being able to loop and display the categories the way I wanted. But am now faced with another problem. I created an edit link on each categories passing it category id, but I got this error: ErrorException in 775837465f5ab64876c1dc1677878595 line 46: Trying to get property of non-object (View: /resources/views/backend/categories/edit.blade.php)My controller public function edit($id) |
Re: Create A Nested Lists Of Categories In Laravel 5 by chiwex(m): 10:31pm On Aug 26, 2015 |
I will post my own codes tomorrow |
Re: Create A Nested Lists Of Categories In Laravel 5 by jacob05(m): 10:45pm On Aug 26, 2015 |
maekhel:It's most likely that $categories = Category::find($id); found nothing but passed as null and the view is trying to access it's property |
Re: Create A Nested Lists Of Categories In Laravel 5 by maekhel(m): 10:57pm On Aug 26, 2015 |
jacob05:It actually found something, cos if I comment out looping thru the categories to create select menu it works. But that does give the options to select from other categories in the database. Hope you got wat I mean? |
Re: Create A Nested Lists Of Categories In Laravel 5 by jacob05(m): 11:04pm On Aug 26, 2015 |
maekhel: Let's see how you implemented the Models and the Views |
Re: Create A Nested Lists Of Categories In Laravel 5 by maekhel(m): 1:04am On Aug 27, 2015 |
Thanks guys for your help, working as expected now. 1 Like |
Re: Create A Nested Lists Of Categories In Laravel 5 by Nobody: 4:16am On Aug 27, 2015 |
Thank God for the great programmers on nairaland. No mind me, na old-school troll i be thinking that laravel is the same as SQL. |
Re: Create A Nested Lists Of Categories In Laravel 5 by maekhel(m): 7:21am On Aug 27, 2015 |
MuhammaduBuhari:Lol |
Re: Create A Nested Lists Of Categories In Laravel 5 by Nobody: 8:40am On Aug 27, 2015 |
maekhel:Na olodo i be, so you fit laff. |
Re: Create A Nested Lists Of Categories In Laravel 5 by jacob05(m): 9:30am On Aug 27, 2015 |
maekhel:Good |
Re: Create A Nested Lists Of Categories In Laravel 5 by CRAZYMADMAN(m): 2:48pm On Aug 27, 2015 |
So many laravel folks here. I wonder how many zend users we have on nairaland |
Re: Create A Nested Lists Of Categories In Laravel 5 by Nobody: 5:16pm On Aug 27, 2015 |
CRAZYMADMAN:We need to do a census one day. I am surprised that we have so much laravel folks as well. |
Re: Create A Nested Lists Of Categories In Laravel 5 by jacob05(m): 5:39pm On Aug 27, 2015 |
MuhammaduBuhari:Yea.. Laravel Rocks !!! 1 Like |
Re: Create A Nested Lists Of Categories In Laravel 5 by Nobody: 7:43am On Aug 28, 2015 |
Eya pele come to Yii2 we got that covered. I don't really like L5 , haven't seen any spectacular reason to jump board. 1 Like |
Re: Create A Nested Lists Of Categories In Laravel 5 by Nobody: 7:45am On Aug 28, 2015 |
CRAZYMADMAN: Zend is for masochists. Too complex 1 Like |
Re: Create A Nested Lists Of Categories In Laravel 5 by danvery2k6(m): 8:51am On Aug 28, 2015 |
pcguru1: You don't know what you are missing out on. Try it, I assure you, you won't regret it. |
Re: Create A Nested Lists Of Categories In Laravel 5 by Nobody: 9:17am On Aug 28, 2015 |
danvery2k6: Don't get me wrong, I know it's awesome but for me i just feel comfortable with Yii2 and it's clean API and all. got nothing against L5 but i will try it our for a project to test, but am not one willing to pick another templating language when PHP template works. |
Re: Create A Nested Lists Of Categories In Laravel 5 by maekhel(m): 3:49pm On Aug 28, 2015 |
Guys, I need your help in another thread https://www.nairaland.com/2559716/populating-select-menu-model-user |
Re: Create A Nested Lists Of Categories In Laravel 5 by koechb: 3:54pm On May 30, 2017 |
Did you get the answer to this working to something related want to list just like this Fashion Accessories - Bags - Cloths Mobile Phones - Tablets - Smartphones I am using laravel 5.3 now |
(1) (Reply)
Trivia Coding Questions (euler Project) / What Is Xvideoservicethief? / What Does It Take To Develop An Ecommerce Site Like Ebay & Amazon
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 38 |