-
Is it deprecated to make factories and seeders in services? I feel like it should be properly decided and updated whether services should have separate database folders or share the laravel project's and maybe just have folders there. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I am currently using standard seeds and factories. |
Beta Was this translation helpful? Give feedback.
-
@mwkohler if you had generated a service with
Factories
use App\Services\Chat\Database\Factories\MessageFactory;
protected static function newFactory()
{
return app(MessageFactory::class);
}
Seeders
use App\Services\Chat\Database\Seeders\ChatSeeder;
public function run()
{
$this->call([
ChatSeeder::class,
]);
}
Thank you @mwkohler for raising this topic that's certainly important and missing from the docs, I will be adding these instructions to the docs under a "Database" section. |
Beta Was this translation helpful? Give feedback.
@mwkohler if you had generated a service with
lucid make service {name}
there should be adatabase
folder generated automatically with the following structure (assuming the service name isChat
):Factories
autoload.psr-4
add"App\\Services\\Chat\\Database\\Factories\\": "app/Services/Chat/database/factories/"
So your
composer.json
should have a similar section as this: