hey friends welcome back to BitFumes I'm your host Sarthak and you can also
call the Ankur this is a channel where I talk about the Laravel and the cool thing about
Laravel so if you are new to distil don't forget to subscribe the important thing
is subscribe okay so in the last episode we have learned about the pagination and
simple paid nation but in this episode we are going to see the pagination in
the relationship eloquent relationship so for that we have the two tables here
the hostel is users tables in that in this table we have world and we created
this pagination system we are on the fourth page if you type second we are on
the second page so like this but we have another table called test table and we
have some data here and obviously this table is related to user's table by this
user ID so we have users let's open in new tab now we have the user with ID of
72-73 so let's see is there 73 no 70 tools there 74 is there so what I want
to do I want to just connect this table with our test table so let's see how
we'll connect these two tables again it's very simple you just have to go to
your usual model actually what I want to do I want to connect user with the test
table so let's see what we have to do we have to create a function here called
obviously test and here I will return return what returns this and I will say
has many what obviously test okay for this for the testing of this system
let's go to command prompt and here I will open this be artisan tinker ok and
and now I will just you the electron system so I will just use
this so it will open every user here so I want to find only one user with the ID
72 so user is here and now what I want to do I want to just get the test system
from this for this model so let's see it is giving me the data
related to this user so for this system we have the name so let's see little bit
because here is also named here's also name it is little confusing so let's see
and make it let the last key so it will be very clear so it will be laughing
okay so actually what we are doing we are doing just simple thing we are
connecting the name with the last name by using this test table so let's see we
have this okay last name is this for a user off professor something-something
okay now now what I want to do let's say a single person has two or three or four
firming that is not that is not possible but in our case everything is possible
so let's just connect more than four or five last names to single use it and
this will look funny but I have want to do this because we have to see the
relationship pagination so for the pagination so here I will also save 72
oh it will be 32 none so 72 again turn to do handle losing some what the name
of this user professor Anibal John has the name of Miss finish him some people
I don't know so next thing is also 70 to
72 it's looking very funny but this let's see what the result is now I go to
here tinkers click this system and you will
hit more than full of five last name for single user very much funny okay so what
I want to do I want to show here the last name also so here I will just say
in our view and I will say the last name not name and here I will obviously see
the last name and obviously we will get the error because we does not have any
last name field in our user table so what we are going to do we have to just
say here text and now here I will say inside this last name and now when i
refresh it will give me errors because undefined index last name it is giving
me error because I have more than one last in here so that's why I cannot do
here the simple thing - what I want to do I want to just find a simple person
that you find with ID of 72 we are finding a single user with the ID of 72
now let's see here what it says so I want to look through the last name only
so was the simple last name here I will say users test and here I will say last
name and here the last name and also the variable will be lost me and delete this
now go to the chrome hit refresh so the error is here I want to say 72 let's go
quick refresh call 211 link he does not have the petition and we are giving the
link so let's just quickly comment this out hit refresh and now you can see we
have the seven last name for a single user of ID 72 so now what I want to do
want to create the painting nation for that I will go to my user model and in
fact its relationship I will say pigeon eight and let's say two and let's go to
Chrome and hit refresh so we are getting this error wire because in our view we
have just used this system so we have to say this as a method so now when I hit
refresh and you will get here two results only and again if you want the
link and obviously you want the link so here you have to say obviously the test
and it's simply done you can see it's again easy and simple what you have to
do you have to just define the origination system in your relationship
obviously okay so if you want to create five users or the five data inside a
page so let's go here hit refresh you will get only five results in a single
page so here I am with the pig nation and this pagination system has completed
so now we have this pagination completed so I will just delete this request and I
will work on these other requests also and you will get your request completed
very soon and if you want to learn new things please request me and obviously I
will note down here in mine one note and obviously work on that system so we will
meet in the next episode with some awesome trick of this level and if you
have any doubt in this episode or in any of my videos please feel free to comment
me you can also message me on Facebook so that we can chat easily and please
follow me please like bit tombs on Facebook Twitter and Instagram and share
this video with your developer friends so that everyone gets the knowledge of
best thing called you know the and we'll meet in the next effort till
then goodbye