V
V
VladimirKrasnov2021-01-18 11:07:39
Laravel
VladimirKrasnov, 2021-01-18 11:07:39

How to work with seeds in Laravel?

There is a small test project (online store). Quite often I refresh my migrations. The problem is that when publishing products, you need to select a city, for this I climb into pgadmin and paste my dump there. Is it possible to automate this business somehow with the help of seeds? What would not be fake cities, but real ones?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladislav Lyskov, 2021-01-18
@Vlatqa

yes, that's what they exist for.

A
Alexander Talalaev, 2021-01-18
@neuotq

Seeds are intended for a slightly different purpose, their main goal is test automation, and therefore the set of methods is appropriate. Well, by default, they cannot be launched on production (only using the --force switch). But how then to separate the seeds for the data and for the test? In short, not an option.
You can just use migrations. You can write logic and so on in them, including initialization and or loading of any data by default into the database.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question