Laravel 5.4 Tutorial | Database Seed #1 | Part 29 | Bitfumes

Laravel 5.4 Tutorial | Database Seed #1  | Part 29 | Bitfumes

Hey Friends, welcome back to BitFumes
I am your host Sarthak and you can also call me Ankur, this is a channel where I talk about Laravel and the cool things about if you are new to this channel don’t forget
to subscribe this is very important thing okay so in this episode database
feeding of the level so why do you need a seed but before that what is seed so what
is reading so the ceiling is just the way of putting a dummy data inside your
database so why you need seeding let’s say you have this user table and inside the
user table you have name email password and if you want to test your system you
have just created so you want obviously that data inside the user table so if
you need two or three data you can honestly put that data in by using the
insert option or by using the system you have created but when you need 50
hundred or even 500 role in your table then how will you do that so to save
your time to save every effort you will put in creating a dummy data then here
is the data base CD so let’s see how this work you can see we have this user
table and go to this database folder we have already known what the database
folder reach because we have generally world with a migration but it’s now time
for PD okay please so let’s see what what this
folder has this photo has database feeder dot PHP database peter dot PHP
let’s see what is inside this inside this there is something we does not know
okay so for there I will just go to the level
documentation and so in this documentation when you go little down
you will see drifting so let’s just open this and paste it here and let’s see
what happens so obviously have given something like TB okay
and table that means DB tables user uses we are working on the user table and now
Alfred name will be STR random ten email the FD a– renders again factory password will be decrypted of secret world okay so how will we insert
this data inside our database so for that we will go to our command prompt
and we will type PHP artisan seed okay let’s see okay sorry we have to do DBC
seat okay now we have successfully turned that means we does not have any
error so let’s see what happens behind the scene so we will go to our database
and when i refresh here you can see there is a things like dummy data and
you can see this is the random number a random word this is also a random word
which is created by this command okay so obviously we can see if we want to
create our dummy data we are ready to go but now this is not the real use of see
ever told you we want to create lots and lots of data in one go okay so how do we
create that because this system has only created one row but we want Christy row
so let’s see how we will do that for that
let’s just go to sublime text again and undo everything from here and let’s type
here Factory and here I will say app user here I will say + comma 50 and now
let’s just use the create command and you stood and let’s go run the
command and you can see it is unable to locate factory with the name default app
/ you okay here is the problem capital Q and let you again try to run
the demand and you can see it’s taking time and no error that means we have
done something so let’s see what something is we will go to the user
tables click refresh and now you can see there are 50 row created so let’s see
all these rules so we expecting 51 rows that means one row from the last command
and fifty row from this command and you can see this has original name of
something okay so this has a name with a email id also and password and something
something else okay so you can see the see this function is used to create the
user but we have to see what this command says this command says use the
factory and forex factory for that when you will go to this database screen
folder and inside that factories folder you have model factory let’s see what is
inside this model factory you have a factory defined I have use it flat and
we have actually used this factory by giving the app user class name okay and
what it says it says create a user by using a fake generator faker okay so we
are using faker and faker is creating a name clicker is creating a unique email
picker is creating the password with big trick of secret word and remember token
of random number so in this command this command is going to
run fifty times that means it is creating the 50 users your table so if I
say here let’s say 10 and save it and run the
command so we elect psychic more 10 users inside our table select C we want
61 that is correct we have the 51 users inside our table
and these all are unique so we have seen that we have created the rows inside our
tables and lots of rules so the next thing I want to show you is that let’s
say we have a new table called let’s say set it’s a testable and
testable has ID test table has user and this ID and s table has a minimum so IDs
good name will be rather or let’s say one language and now save it so we have
created our table and you can also create this table by going to the
migration system but I have proposed this system so that’s not the that’s not
a point of debate so let’s go and if I want to create many of the rules inside
this table inside is steps table so go here and what I want to do I want to
create here obviously I want to say it and I want to comment this out so let’s
see how we will do that obviously we won’t run the command but it is giving
an error so why this error because then we have used factory it is it is giving
me no but we have getting the error so we will resolve this error in the next
video so if you have any doubt in this episode please feel free to the main me
if you have any doubts in other videos or anywhere of your projects please feel
free to comment me I will always respond and read
help you you can follow me on Facebook Twitter and Instagram you can message me
on Facebook where I am very active please like the things on Facebook so
that you will get the latest update about what is coming and what’s going on
in the Bristol Channel so we will meet in the next episode and it till then be
happy goodbye and share this video with your
developer train

Danny Hutson

11 thoughts on “Laravel 5.4 Tutorial | Database Seed #1 | Part 29 | Bitfumes

  1. *************************************************
    Could you make videos about the course creating real project which has many functionality(such as chattting service, blog or shopping mall)

    I love your video so much.
    Your video is a good reference to me.
    I hope you making videos included deeper knowledge on laravel.

Leave a Reply

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