Skip to content
This repository was archived by the owner on Apr 16, 2024. It is now read-only.

Commit 4de6e54

Browse files
author
Alex Giuvara
committed
'php artisan migrate' without --path
1 parent 9b9aacc commit 4de6e54

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/Generators/ServiceGenerator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class ServiceGenerator extends Generator
2828
protected $directories = [
2929
'Console/',
3030
'database/',
31+
'database/factories/',
3132
'database/migrations/',
3233
'database/seeds/',
3334
'Http/',

src/Generators/stubs/serviceprovider.stub

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,35 @@ namespace {{namespace}};
33

44
use View;
55
use Lang;
6+
use Illuminate\Database\Eloquent\Factory as EloquentFactory;
67
use Illuminate\Support\ServiceProvider;
78
use {{namespace}}\RouteServiceProvider;
89
use Illuminate\Translation\TranslationServiceProvider;
910

1011
class {{name}}ServiceProvider extends ServiceProvider
1112
{
13+
/**
14+
* Bootstrap migrations and factories for:
15+
* - `php artisan migrate` command.
16+
* - factory() helper.
17+
*
18+
* Previous usage:
19+
* php artisan migrate --path=src/Services/{{name}}/database/migrations
20+
* Now:
21+
* php artisan migrate
22+
*
23+
* @return void
24+
*/
25+
public function boot()
26+
{
27+
$this->loadMigrationsFrom([
28+
realpath(__DIR__ . '/../database/migrations')
29+
]);
30+
31+
$this->app->make(EloquentFactory::class)
32+
->load(realpath(__DIR__ . '/../database/factories'));
33+
}
34+
1235
/**
1336
* Register the {{name}} service provider.
1437
*

0 commit comments

Comments
 (0)