Skip to content

Commit 7b91daa

Browse files
Merge pull request #36 from vkislichenko/feature/manual-migrations
UPDATE: Manual migrations option
2 parents 563c22a + 7f2c521 commit 7b91daa

File tree

4 files changed

+45
-5
lines changed

4 files changed

+45
-5
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ composer require stackkit/laravel-database-emails
4343
Publish the configuration files.
4444

4545
```bash
46-
php artisan vendor:publish --provider=Stackkit\\LaravelDatabaseEmails\\LaravelDatabaseEmailsServiceProvider
46+
php artisan vendor:publish --tag=laravel-database-emails-config
4747
```
4848

4949
Create the database table required for this package.

config/laravel-database-emails.php

+13
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,17 @@
7171
*/
7272

7373
'immediately' => env('LARAVEL_DATABASE_EMAILS_SEND_IMMEDIATELY', false),
74+
75+
/*
76+
|--------------------------------------------------------------------------
77+
| Manual migrations
78+
|--------------------------------------------------------------------------
79+
|
80+
| This option allows you to use:
81+
| `php artisan vendor:publish --tag=laravel-database-emails-migrations` to push migrations
82+
| to your app's folder so you're free to modify before migrating.
83+
|
84+
*/
85+
86+
'manual_migrations' => (bool) env('LARAVEL_DATABASE_EMAILS_MANUAL_MIGRATIONS', false),
7487
];

src/Email.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class Email extends Model
5353
*/
5454
public static function compose()
5555
{
56-
return new EmailComposer(new self);
56+
return new EmailComposer(new static);
5757
}
5858

5959
/**

src/LaravelDatabaseEmailsServiceProvider.php

+30-3
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,43 @@ class LaravelDatabaseEmailsServiceProvider extends ServiceProvider
1212
* @return void
1313
*/
1414
public function boot()
15+
{
16+
$this->bootConfig();
17+
$this->bootDatabase();
18+
}
19+
20+
/**
21+
* Boot the config for the package.
22+
*
23+
* @return void
24+
*/
25+
private function bootConfig(): void
1526
{
1627
$baseDir = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
1728
$configDir = $baseDir . 'config' . DIRECTORY_SEPARATOR;
18-
$migrationsDir = $baseDir . 'database' . DIRECTORY_SEPARATOR . 'migrations' . DIRECTORY_SEPARATOR;
1929

2030
$this->publishes([
2131
$configDir . 'laravel-database-emails.php' => config_path('laravel-database-emails.php'),
22-
]);
32+
], 'laravel-database-emails-config');
33+
}
34+
35+
/**
36+
* Boot the database for the package.
37+
*
38+
* @return void
39+
*/
40+
private function bootDatabase(): void
41+
{
42+
$baseDir = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
43+
$migrationsDir = $baseDir . 'database' . DIRECTORY_SEPARATOR . 'migrations' . DIRECTORY_SEPARATOR;
2344

24-
$this->loadMigrationsFrom([$migrationsDir]);
45+
if ($this->app['config']->get('laravel-database-emails.manual_migrations')) {
46+
$this->publishes([
47+
$migrationsDir => "{$this->app->databasePath()}/migrations",
48+
], 'laravel-database-emails-migrations');
49+
} else {
50+
$this->loadMigrationsFrom([$migrationsDir]);
51+
}
2552
}
2653

2754
/**

0 commit comments

Comments
 (0)