April 2, 2020
#10 Sorting Products according to categories || E-commerce Website in Laravel 5.5

#10 Sorting Products according to categories || E-commerce Website in Laravel 5.5

okay friends in this video we will sort
the product according to category for example I will show you I have in some
products strawberry cherry orange garage Amman chocolate and I catalyze into
three categories named through very table sweet okay if like / here and good
here very tables must be short right which product have this category ID okay
we will do it all dynamically according to our category ID and we will make join
two tables so go to your favorite editor open route Feb dot php’ after where you
are displaying all here you will put new route name it products / here is
parameter call cat you can name it anything and here you will put product my model name is wait a minute
my controller actually products controller products controller here is
product controller at the date there you will make new function broken okay save
it what will your product controller here you will create a public function yes okay it will be request your parameter
and let me show that parameter request and parameter name is get so low let me
check here and here is your parameter nice save it as a variable call it cat
now we need a query where we will return data according to our category join with
table name is products we are choosing here join with table in scats weird cats
both ID m equal to 4 bucks . and
we need beer can be sin condition is X dot cat named equal to this cat
parameter and get function here is vegtables have a two products let me be
in the category sweets and sweets also have multiple product strawberry
chocolate log gum and cherry everything’s you can put here and third
win flow and fruit away three products orange grapes o Mela Oh Milo I think ok
if user click on only products they can see all products now we need here make
it you same like this view but according to
category and we will show in our breadcrumbs here if category have not
any products for example I put any randomly
and zero we will display error message custom error message okay so now open
here go to editor we will save it to data and here three-ton view it done
view average foreign dot products as you will let me know and here you will put
here data simply data variable save it go to hell refresh and you have it I
forget to accent Allah say with the Lord now you have a three products by fruits
category let me check through it ok it’s sweet yes so here is five products under
Steve’s veg’table here is now we need open our products view front folder
products blade inside for each we will put here if data is empty that means let
me show you account we will put air count to see what we are getting you get
in here here and here you get in here – we want to display that so we will get
here leave out equal to e o and we will display our own message
our sorry not curly brackets only this else we will display for each with our
dynamic data and end off and if statement okay
inside here we need to display you can say same view of so we will copy this to
do close tag or div inside this we will put our own message no products you can
choose anything here no products found under this and make it a line that save
it make it wrong spelling you can see no product found here I think I make it
full width okay here is data I am NOT going to deeply this design that’s all
okay no product found under this category but we need to display category
name here here which is coming from it so for that go to your route no I mean
that controller make here get by using name it anything yes we need to pass
this parameter okay inside this you will find air just kept by user and make it
little bit bold that will be fine I think
and close your BTech save it now you can see no product found under this category
and we need to display here also here you will display simply add spice user
save it here is your bread crumb now here also you need to define some parameter if statement is count equal to
0 then you will displays like this but else and here let’s copy this okay and
here you will put only be tag because we don’t have this name of category but
here you have a category URL and your route name is products and here’s your
slash your catch by user that’s all
let me see what is going on okay now it’s only volt not a negative but if put
here at your category now I must have a anchor tag which is not displaying okay let me try a G tables it’s not anchor
tag let me find out why just only voyage else is category the data is empty no it’s all fine let me change this to
check edge save it no it’s not changing that means we have already this data
actual data now make it wrong you have a raw data but not same if count oh sorry
is count here not save it reload now you can see let me try with actual and you
have a cat now let me make it yet by user yep your anchor tag is product
fruit so that means is same so that’s nice it’s your bread crap okay
now you can see if I put here and he randomly categoryname it will gives you
no product from okay you can hide this also let let hide this which this is
daro and this here is you will put only if not zero then it will show and is
save it we lot now you need second one also so just put peers load okay if you
need to reload with fruit you can see all this and wrong category not found
category you can not can’t see this and you can hide this also and inside here
you will put category pies user that’s it let me show you here to root and you
can see fruit here ok next time we will catalyze this by
brand price sort so and much more we will do it our account search also we
will do it all in the next upcoming videos thank you guys

4 thoughts on “#10 Sorting Products according to categories || E-commerce Website in Laravel 5.5

  1. Sir that Product Controller function proCat where is the cat come from
    public function proCat(Request $request){

    $cat = $request->cat;
    Plz reply sir

Leave a Reply

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