Answer the question
In order to leave comments, you need to log in
Laravel 5.3 category tree implementation?
How to correctly implement the relationship between the category parent and child to build a tree?
After all, there is only model 1 , the column in the database - parent_id, allows you to display all categories from the category.
I implement it in such a way that I go through all the categories with a recursive function , where the names are displayed and check if there is a parent, if there is, then it goes into it and so on in a circle.
I'm not sure if this is correct, perhaps in Laravel 5.3 this should be done somehow differently?
How would you do?
Answer the question
In order to leave comments, you need to log in
Closure Table. Lara package: https://github.com/franzose/ClosureTable . Works very fast even with a large number of categories/subcategories
else
not there. We need it as an alternative to the first if
'y:
<?php
if(isset($_SESSION['logged_user'])){
if($_SESSION['logged_user']->id > 0 ){
echo '<p class="auth">'.$_SESSION['logged_user']->names.'<br>'.$_SESSION['logged_user']->full.' руб</p>';
}
}
else
{
echo 123;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question