Database Seeding in laravel 10 | Database Seeder in laravel 10 | Master Fulll Database Seeding

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi guys I am Shazam and welcome on our YouTube channel today's we're gonna discuss about the CD how exactly you can see your data or their data tables by using the seeders available in the laravel 10 so for those person who just join us on our YouTube channel I request them please click on subscribe button and pressing the Bell icon so you never miss any update so let's get started okay guys so now you are fully familiar with the model migrations so now if you talk about the seeders you can seed your tables or your database by using the seeders so first of all you have to create the serial class so it's available in the database as you can see in the database you have the seeders so now I'm saying CLS first of all so you need to create the serial class now I'm saying PHP in artisan make Cedar you have to Define your Cedar class let's suppose I am saying subject Cedar fine just click on the intro button the subjects either available here so here as you can see it's saying run so now here I'm saying I need to create the DB DB who insert the record I'm saying table which is my subject table so we can see the subject tables subjects I am saying name or name of the table which is the subject and now here you can use the insert insert method and insert method takes associative array first of all the name of the column that's the post name the value let's suppose I am saying Java and also comma separate three values for C columns so you know very well the class I'm saying this is for uh Juniors or beginners and now the price the price for sorry it's price and price for the beginners is I'm saying 20 so this is the first result the second result you can separate with the like this now so these are the three difference I'm saying coordinator I'm saying beginners so it's 100 and now if you talk about the I'm saying take PHP or falcon or if I say that Django or python anything any language or any framework so it's also let's suppose I'm saying 250. so you have one array you have second edit you have third error make sure you are passing the array so that's why you have to use the created and also the updated foreign so now how can you run the cedar you can run the seeder by using the command I'm saying PHP artisan PHP artisan DB seed so when you use this command so that the system automatically executed all the DBS available here you can Define the device like we have defined here you can attach this one and run this command so now I'm saying class I'm specifying which class you need to execute so copy this one this class hit the intro button so now as you can see seeding database so now go to the page refresh the page as you can see you have the Java and the values are generally why because you have to Define these one since this is the create method that is the so this is my iPad so I have to create this in specific error so this is the array and now we have this value since we have already created this one Java and also we have to use the carbon carbon carbon now method for the columns which columns I'm saying uh The Columns inserted at inserted at and also updated [Laughter] updated ad make sure separate column separate column and also separate all fine I am saying Java to for now so now I'm saying run this again it's saying column not found a non-column inserted at fine so now sorry it's not inserted right it's created at created ad and also the updated ad I thought I am using the coding name so it's created ad not inserted once again hit the enter button you are seating fresh the page so now you have the Java coding matter and also the python so here in this way you can use or you can use the Cedars to seed your database so let's suppose uh if I say PHP Artisan uh migrate migrate and I'm saying refresh foreign just hit the enter button so now you are roll back your whole backing and now as you can see this is the empty but when you check the subjects so you will have the seeds here now why not it's here because you have to Define which Cedar you are going to execute since you are executing the cylinders manually so now you have to define the cylinders here database okay so now I'm saying this I'm saying call and here we have to define the subject seated and then Plus so you have to Define subject 6 if once again now I'm saying fast Define you have to give the Colony we forgot the columns once again seeds as you can see subject seeders you have running and you have done so now once you open this one so now we have the Cedars we have used the migrations and we have successfully inserted our seen our tables so now I'm going to remove the Java first of all Java coordinator and this is the python and why not the laravel I'm saying that away laravel for beginners it's very costly so you know very well that we are using carbon now to add the current date so once again HP Artisan refresh sales fine so here laravel Java coordinator python you can also insert the default values in any tables by using serial okay so now let's suppose I'm going to create the Factory let me create it CLS okay so now I am saying PHP artisan make Factory and now I'm saying subject Factory and the model name is model name is the name of the model so since the name of the model is there is a model so this is the model ing subjective so you have to give this model name fine just get the enter button we have successfully created the factory in the factory as you can see you have the subject Factory now here you can Define the data which you want to insert so let's suppose I'm saying that I need the name sorry I need the name let's suppose I'm saying use the use the faker and now I'm saying uh name so they don't have the subject so that's why I'm using the name name and also see other fields you know very well that this is the class and this is a subject uh sorry price so class and price so now if I say price faker price surprise I think not available address is available string so let's suppose I am giving the address here because address is available and now I am using the random or iPhone the random digit random digits so now you have created the definitions so now in the user Factory which is the this one I am going to comment this one here I'm saying subject model and I'm saying Factory and now I'm saying count uh I'm saying 50. 50 records or let's suppose I'm saying 60 or 30 records and now I'm saying create so if you are inserting the manually you can use them manually otherwise we have defined the serial class here so now once again CLS I'm saying refresh factual sorry we are migrating fine so running so now check the data so you have the 50 records or the 30 records we have used so in this way you can use the factory to insert the data to feed the data by using the seeders okay guys so in this way you can seed your data by using the cedars in laravel 10 so I have guys you are enjoying our videos If you think we are doing good thumbs up feel free to share our courses with your friends especially on social networks and please support us and our Channel by clicking subscribe button and pressing the Bell icon so you never miss any update so thank you for watching
Info
Channel: Shakzee
Views: 1,644
Rating: undefined out of 5
Keywords: Database Seeding in laravel 10, Database Seeder in laravel 10, Master Fulll Database Seeding, laravel 10 seeding, laravel10 seeders, laravel 10 seeding database, laravel 10 database seeding, database seeding laravel10, database seeding laravel 10, Laravel 10, Database Seeding, Laravel Database Seeder, Laravel Tutorial, PHP Framework, Coding Tutorial, Web Development, Laravel 10 Beginners Guide, seeding in laravel
Id: XwqcCfd6PKM
Channel Id: undefined
Length: 14min 10sec (850 seconds)
Published: Mon Jul 03 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.