I would like to create one of my seeders' object in some migration in order to use some of its functions. Is it possible?
Asked
Active
Viewed 229 times
-3
-
I did not understand what you need – Giacomo M Mar 03 '22 at 07:36
-
Please use the proper terms and be as descriptive as possible. What do you mean by "Seeders' object"? What "functions" are you using in your migration? Do you mean class? Your question needs to use familiar and correct keywords to be understood properly. You are also expected to provide segments of the code you are using if you want to save yourself and the community the time of understanding the exact problem. – gowl Mar 03 '22 at 07:42
1 Answers
1
You can call direct DB or Eloquent call inside your migration but it is not recommended. Because it may break your deployment.
However, if you like to use some model inside your migration you can call your model query directly. Like below:
User::where('email', '=', 'test@gmail.com')->first();
Or if you want to create some model directly :
$user = User::factory()->create();

gguney
- 2,512
- 1
- 12
- 26