From the course: Building a Website with Laravel, React.js, and Inertia
Creating a seeder and a factory - Laravel Tutorial
From the course: Building a Website with Laravel, React.js, and Inertia
Creating a seeder and a factory
- [Instructor] Let's create a factory and a seeder and see the database with some fake posts. We could just add data some manually in the database, but why not use the tools Laravel provides us with? It's quick, it's straightforward, and we can see the database over and over again in case we make a mistake somewhere down the road. In the post factor dot PHP file, we will update the definition method and use faker to fake the author, title, and body values. I'm going to leave these as they are for now. We could have been more creative here. For example, give the paragraph more sentences and you could go ahead and do that. But I'll move on to creating the seeder. In the post seeder dot PHP, we will create 10 posts, and now we can see the database by running PHP, artisan DB seed post seeder in the terminal. If we check Table Plus or any other database query you may be using, we will see that we have seeded 10 posts in the post table. In the next lesson, we will create a post API resource.
Contents
-
-
-
(Locked)
Getting started: Creating a new Laravel project1m 59s
-
(Locked)
Creating a Post resource1m 51s
-
Creating a seeder and a factory1m 15s
-
(Locked)
Creating Post API resource1m 27s
-
(Locked)
Creating PostController index and store methods4m 25s
-
(Locked)
Creating PostController show, update, and destroy methods2m 14s
-
(Locked)
Challenge: Testing API Endpoints with PHPUnit1m 55s
-
(Locked)
Solution: Testing API Endpoints with PHPUnit3m 57s
-
(Locked)
-
-
-