'Can I create Seeder's object in migration in Laravel?
I would like to create one of my seeders' object in some migration in order to use some of its functions. Is it possible?
Solution 1:[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', '=', '[email protected]')->first();
Or if you want to create some model directly :
$user = User::factory()->create();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
