[Laravel 7 Lesson 12] Factories & Seeders (Seed database with faker data)

preview_player
Показать описание
[Laravel 7 Lesson 12] Factories & Seeders (Seed database with faker data)

In the 12th lesson of our Laravel 7 from the ground up series, we're going to start by removing our PostController, Post Model, and posts table and associated table migration.

Crazy? How come you ask, well honestly -- because we can create all of those files plus two more within a single artisan command.

Within four minutes, we will review our lesson, remove the model, controller, and migration, and then re-create the model, controller, and migration.

For the remainder of our lesson, we will focus on factories and seeders, ultimately populating our database with dummy data.

~~~~~~~~~~~~~~~~~~~~
Clean Code Studio ~ Simplify!
Clean Code Clean Life
~~~~~~~~~~~~~~~~~~~~

~~~~~
Github
~~~~~~~~~~~~~~~~~~~

~~~~~~~~~~~~
NpmJS Packages
~~~~~~~~~~~~

~~~~~~~~~~~~~~~~~~~~~
Packagist (Composer) Packages
~~~~~~~~~~~~~~~~~~~~~~

~~~~~~
LinkedIn
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Looking for hosting? Three options to consider
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1. Laravel Forge is my go to for monolithic apps.
- You'll need a digital ocean or AWS server
- Laravel Forge starts at $12/month + the cost of your server
- Expect to pay between $25-$50/month with cost variance depending on your server
(Note: Hostgator is the most cost friendly hosting and linked to below).

Laravel Vapor is my go to for Serverless non-monolithic applications
- Vapor needs to be connected to an AWS account
- Vapor itself will run you $39/month + the cost of your aws cloud infrastructure
- Apps expecting major traffic needing horizontal scaling capability may want vapor.
- Price point: Expect to spend $100/month and be happily surprised if its less. The price for serverless majorly varies based on proper configuration and traffic. If everything is set up properly, and you have a lot of traffic serverless will spend you money. That being said -- it's nothing short of complex. Vapor simplifies the complexity of serverless cloud computing to an extent. Price point for Laravel Vapor per month with Aws setup: $90 to A lot of $/month.

3. Hostgator
- Starts at $2.75/month
- Cost-friendly
- Beginner friendly
- Not as powerful or configurable as Forge or Vapor
- Solid hosting provider for small sites like your portfolio
- cPanel offered with upgraded plan, also easy to upgrade

Рекомендации по теме
Комментарии
Автор

good content and not boring. this is GOLD

yongkitanumiharjo
Автор

Great video. I think I'm going to follow the whole tutorial. It's step by step and easy to understand.

fadhilinjagi
Автор

I've liked this video because it's obvious that the author has put his precious time for making this video as much enjoyable as possible, but please notice that Laravel seeders can run query builders as well, they're not limited to use factories. That can be quite useful when the data we're seeding is not completely random to be created using the Faker. Thank you anyways.

mojtabavahdati
Автор

I think u are one of the most underrated channels on youtube ... great video man, u got my sub for sure

ahmedsobhy
Автор

How do you do one to one relationships with Factories?

justtestingmycurrentskills
Автор

Como agrego un campo faker de una fecha yyyy-mm-dd hh:mm:ss con la condición que sea en el mismo mes que se crea. Tengo esto pero no me genera el formato y por otro lado me genera un fecha muy distante.
'start' => $this->faker->DateTime,

'end' => $this->faker->DateTime,

arlingholguin
Автор

my tinker is working but when i try seeder it shows ( throw new class [$concrete] does not exist.", 0, $e)
my model name is Todos,





Target class [TodosSeeder] does not exist.

at
803|
804| try {
805| $reflector = new ReflectionClass($concrete);
806| } catch (ReflectionException $e) {
> 807| throw new class [$concrete] does not exists")
ReflectionException::("Class TodosSeeder does not exist")

2

BhupendraTool
Автор

I recommend having a look at how CakePHP deals with fixtures using factories:


pabloinberlin