#13 Laravel Multi Level Category || E-commerce Website in Laravel 5.5


okay guys in this video I will try to
create multi-level category functionality as you can see we have a
three category fruit vegetable sweets and I will insert more category under
this this three category name will be parents and we will introduce new
categories as a child for that first of all we have to change the structure of
cat table here you will add a new column or field you will save P underscore ID
and save it as a integer okay here you have a parrot ID fruit vegetable sweets
will be remain zero but which we will insert here neon category like a good
fruit bad fruit this too will be under weight River category one okay just put
here one and save it go to browser you can see we have a ID number twelve and
thirteen under this belongs to ID one that’s it
insert two more like a good sweet at sweets
I know it’s funny names you can use any name for this and switch is three I did
so I put V and the score ID is three fill it save it browse now you can see
in browser we have three four five six seven multiple IDs we need to organize
according to upper parent and child my teeth he rated level okay for that
we need to create relationship between these categories table okay go to the
dual favorite editor open cats dot PHP model here public function here I can
say tykes you can use children I know I was used this function will return the
array which will be this has many with AB that’s real name is we underscore ID
okay you check this puke go to your route directory open web dot PHP here
create a new function just use enemy for function like this we will create a new
function and try to run this relationship to see the output here
you will sleep F cash big your function name this one and we’re condition we
need which PIDs zero okay so that means we are getting only peanut id’s zero is
on the logs get function go to browser run your test function test as you can
see here is the array fruit good fruit bed food it’s so simple variable has
nothing so that’s why is something like this child is empty and sweet sweet ever
goes best weight okay now time to fit on this
value according to our levels so go to your master blade because we have a
common navigation menu and here you have it you will I will commit this and
create a new content for you a really you can’t leave it with on it up it
start for each start for it you yeah you can put this we done before get with and
here these giant and let me say we’re conditioned this PID I call the bureau
and the catch I know it’s long function you can use any you want to do that a
variable and here put here item or you can say get something like this and for
each inside this you will put a live anchor and here item catnip close that
anchor tag close egg alike okay go to browser reload and you can
see we have a other categories here you can see you as well
products and here I don’t get name to see the result of products don’t click
on food you can see this fruit click on variable you can see is variable so your
main categories smirking now we need other category else for that in kind of
you here you can see we have a li when we have nothing our child but we have to
define here in condition is account child because I showed you we test here
is the child we are asking to system for child lady row or not here so for that
here I will jump out function more than here then we will say show something
here it has this spot will run okay now and it’s inside this you will put
new ally and of course you need here minute ID also same like this and put
item cat name but made four pills here where you will
start new for each for sub menu so that you can say item guys as some minor and
for each inside this you will start new you a life because you are inserting
creating new many allied here you will say I town get name simply catching okay
Ally don’t forget to add here and cut that okay and go to browser not go to
browse products and you can see here is through very table wait a minute
you have to be a giant reload I think I’m missing something reload route variable sweet okay I need
to display my summoning of actually son my new cat named reload now you can see
here is me and good fluke bear fruit let me create it more real quick fold with
this sign and you can see it’s sweet good sweet bad sweet fruit under good
food and variable is single so make it more beautiful you can put here at four
inside anchor tag we’re also close as three reload now you can see it’s very
people because I think I have it here that’s why I think let me check why it’s
different colors reload here is something s3 okay put this
inside this also okay I put here mistake-free h3 we need at 4k reload now
you can see it’s fruit fruit under this vegetable sweet if you put something
under vegetable like a insert cat name is cat name is good ready and PIDs is
PID – means ready table and check browse go to browser reload now you can see
vegetable has also a new child good becchi that’s nice now time to put here you let me URL products okay and she
lays here you will say sub-menu cat named three note if I click
on good Reggie which is good Reggie but nothing is here so for that we have to
modify this IDs like wait a minute let me remember some categoryid okay good
sweet is 14 and 15 16 we can insert some ID and modify your existed this products
like a 14 15 16 is vegetable good veggie so I will change this to make it to
convert to good value let me check double check 16 is good veggie okay now
nice you note now you can see cucumber is under good veggie this is our multi
level categories and you can add more data under this good true bad fruit and
if someone click on foo they can see root click on value table they can see
vegetable sweets you can modify as you are offended okay thank you voice

Leave a Reply

Your email address will not be published. Required fields are marked *