Skip to content

UPDATE: Manual migrations option #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ composer require stackkit/laravel-database-emails
Publish the configuration files.

```bash
php artisan vendor:publish --provider=Stackkit\\LaravelDatabaseEmails\\LaravelDatabaseEmailsServiceProvider
php artisan vendor:publish --tag=laravel-database-emails-config
```

Create the database table required for this package.
Expand Down
13 changes: 13 additions & 0 deletions config/laravel-database-emails.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,17 @@
*/

'immediately' => env('LARAVEL_DATABASE_EMAILS_SEND_IMMEDIATELY', false),

/*
|--------------------------------------------------------------------------
| Manual migrations
|--------------------------------------------------------------------------
|
| This option allows you to use:
| `php artisan vendor:publish --tag=laravel-database-emails-migrations` to push migrations
| to your app's folder so you're free to modify before migrating.
|
*/

'manual_migrations' => (bool) env('LARAVEL_DATABASE_EMAILS_MANUAL_MIGRATIONS', false),
];
2 changes: 1 addition & 1 deletion src/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Email extends Model
*/
public static function compose()
{
return new EmailComposer(new self);
return new EmailComposer(new static);
}

/**
Expand Down
33 changes: 30 additions & 3 deletions src/LaravelDatabaseEmailsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,43 @@ class LaravelDatabaseEmailsServiceProvider extends ServiceProvider
* @return void
*/
public function boot()
{
$this->bootConfig();
$this->bootDatabase();
}

/**
* Boot the config for the package.
*
* @return void
*/
private function bootConfig(): void
{
$baseDir = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
$configDir = $baseDir . 'config' . DIRECTORY_SEPARATOR;
$migrationsDir = $baseDir . 'database' . DIRECTORY_SEPARATOR . 'migrations' . DIRECTORY_SEPARATOR;

$this->publishes([
$configDir . 'laravel-database-emails.php' => config_path('laravel-database-emails.php'),
]);
], 'laravel-database-emails-config');
}

/**
* Boot the database for the package.
*
* @return void
*/
private function bootDatabase(): void
{
$baseDir = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR;
$migrationsDir = $baseDir . 'database' . DIRECTORY_SEPARATOR . 'migrations' . DIRECTORY_SEPARATOR;

$this->loadMigrationsFrom([$migrationsDir]);
if ($this->app['config']->get('laravel-database-emails.manual_migrations')) {
$this->publishes([
$migrationsDir => "{$this->app->databasePath()}/migrations",
], 'laravel-database-emails-migrations');
} else {
$this->loadMigrationsFrom([$migrationsDir]);
}
}

/**
Expand Down