hey friends welcome back to bitfumes I'm your host Sarthak and you will also call
me Ankur this is channel where I talk about the Laravel and the cool thing
about the Laravel so if you are new to this channel don't forget to subscribe ok so
in this episode we are going to learn about the pagination in the level and
this is the request from we have Imran Khan and AM Advani so you can see I have
written every request I have got from you guys so we will all obviously going
to learn about the famous Edmund getting IP address and last login creating the
manual login registration github sublime text 2 adjectives as X is requested by
most of the subscriber so we will going to learn ejects very soon actually I am
busy on a project so I am NOT able to concentrate on creating a project to
awful adjectives on to show you eject system with a mini project ok
so let's learn about the pagination and it's very very easy you can see this is
the documentation of the level about the pagination so in the last episode we
have learned about the speeding of the database so let's see so here I am in
the database where I have just seeded the 10 used random users inside my users
table and obviously inside our test table so if you don't know amount the
speeding so don't worry check out the link below in the description or you can
search for the ceiling in my channel ok so let's go and create a pagination
obviously I don't have any view for that let's go quickly and create a view so I
will go to my sublime text and go to resources folder view folder and here I
will create a view called let's say pagination dot blade dot PHP okay that's
good and I will use html5 markup and here I will say just big nation and
here I will use this let's say div row and obviously after that this a
container okay so here I will create a table tables with a table head which
says which says table head which has heading of the name and email okay so
let's see we have the name and email of our user to name and email and here
inside our body for tea body here I will say table row and table data
and this data will be like the name and email obviously we are going to fill
these two with the data from our database so let's just check out the
database so we have this database created in the last sort so just get
this data from our controller so we have to create a controller also for that we
have to open a command prompt and I will go to this folder and there is a
shortcut for opening command from flora specific folder so let's press the shift
key and press right click anywhere and you can see now we have the open command
window here if we just right click here we does not have that that option so
with the shift key press this when I press right click then we get the open
command window here so let go and we can see we are on directly on that folder so
I will just type PHP artisan serve and obviously we have to create another
command prompt so the PHP artisan make controllers name
pagination and it created let's go here and we have the pagination and now here
I will say pagination and let's say users otherwise it will be confusing so
here I will return view view of pagination not dot PHP okay so let's
check this system so we will go to our localhost and here I will see so page no
page not paginates users so we does not have any routes so
let's just quickly create the route so here I will just delete this and create
a route of get which says users go to pagination active users and let's go
click refresh now we have the system here which we have created in the
pagination a dot PHP now we just have to connect our system with the database so
obviously we need to import the model use at slash user and we have imported
now here I will use so users is equal to users it will be capital not users its
user and all now with the compact method I will just pass this data to our view
and now I will go to presentation dot blade dot HP and here I will create a
fault each loop and here I will say user as
user and just get it here delete this and here I will just echo that out so
here I will say user name and is obviously user email that's good and
let's see everything is correct yes so let's go click refresh and you can see
we have everything correct so you can make this look better by using the
bootstrap but for the sake of time I am NOT using the bootstrap so let's just
see we have 1 2 3 4 5 6 7 8 9 10 10 users so let's just quickly get here a
table data width which says the loop index what this do this will just create
a numbering of the loop that means every time loop goes it will create the number
for that loop okay so let go click refresh and you can see it is start from
0 but we want to start from 1 to +1 and now we have 1 to 10 numbering now the
time for the pagination it's extremely extremely simple you know why because I
just have to do one thing so what I will do I will just delete this all and here
I will say page in 8 simple and here the number of data I want to show in single
page so we have 2 here so let's go click refresh and you will get an error
because the pagination is spelling is incorrect so it will be paging mate ok
refresh and you will get the data here so you can see it's extremely extremely
simple so now what I have to do I have to create a link to get to next page now
for the link you just have to say here users not user it saves users and here
link so now go here hit refresh and you can see we have the pagination links
here so I will just put it down so that we get pagination links
downside and you you can obviously select this pagination system according
to your view that means if you use Buddha step it will be awesome it will
be inlined and you will get the thing correct so you can do obviously but
let's just see the result so when I hit on the second page it will give me the
second when I on the third third fourth fifth and you get each and every result
here so if you want to customize this let's see how it looks like it says ul
of class pagination so what I can do I can just create a style here a style and
dot pagination and inside this I want Li to be display inline
inline let's go hit refresh and you can see it is in lined and obviously you can
do styling according to you and it will give you the awesome result so this is
the simple thing and so the next thing I want to introduce is the simple
pagination so what you have to do follow the simple pagination just goes up
pagination type here simple page Nate hit refresh and you will get no change
except the links here so in the simple pagination you does not get any number
in between the next and previous only you get the next in previous links so
here next and previous links okay so if if you have a project where you want the
user to go each and every step don't want to skip then this is the way to do
that thing so in the next episode we are going to learn about the pagination in
the relationship eloquent relationship technicians so stay tuned and if you
have any doubt in this episode or in anywhere of my videos please feel free
to comment follow me on Twitter Facebook and Instagram and you
can also message me your problems errors on Facebook and share this video with
your developer friends so that everyone gets the knowledge of best thing called
level and I am going to complete each and every request one by one as I get
the enough time to complete these requests and don't worry as a complete
request very soon and the most important thing as Jack series is coming shortly I
am working on the mini project of adjectives to do not worry and sorry for
the delay and you will get the best thing from Whitfield's and don't forget
to subscribe that is very important thing so we will meet in the next
episode till then good bye