Skip to content

Commit

Permalink
Fix error during installation
Browse files Browse the repository at this point in the history
Fix issue where the config file was read before it was registered. This triggered an
exception during the installation.

Support for Laravel 7.0 has been dropped since it is EOL and won't receive any security
updates anymore.
  • Loading branch information
michielfb committed Mar 31, 2023
1 parent 7367a44 commit 7e06e56
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 10 deletions.
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
"email": "hi@michiel.email"
}],
"require": {
"php": "^7.2 || ^8.0 || ^8.1",
"illuminate/console": "^7.0 || ^8.0 || ^9.0 || ^10.0",
"illuminate/database": "^7.0 || ^8.0 || ^9.0 || ^10.0",
"illuminate/support": "^7.0 || ^8.0 || ^9.0 || ^10.0"
"php": "^7.4 || ^8.0 || ^8.1",
"illuminate/console": "^8.0 || ^9.0 || ^10.0",
"illuminate/database": "^8.0 || ^9.0 || ^10.0",
"illuminate/support": "^8.0 || ^9.0 || ^10.0"
},
"autoload": {
"psr-4": {
Expand Down
54 changes: 48 additions & 6 deletions src/DataMigrationsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,44 @@
class DataMigrationsServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
* Register services.
*
* @return void
*/
public function boot()
public function register(): void
{
$this->registerConfig();
}

/**
* Boot application..
*
* @return void
*/
public function boot(): void
{
if ($this->app->runningInConsole()) {
$this->publishConfig();
$this->registerBinds();
$this->registerMigrationDirectory();
$this->registerConfig();
$this->publishDataMigrationDirectory();
$this->publishMigrationDirectory();
$this->registerArtisanCommands();
}
}

/**
* Register config.
*
* @return void
*/
public function registerConfig(): void
{
$this->mergeConfigFrom(
__DIR__.'/../assets/config/data-migrations.php',
'data-migrations'
);
}

/**
* Register binds.
*
Expand Down Expand Up @@ -60,25 +84,43 @@ private function registerBinds(): void
*
* @return void
*/
private function registerMigrationDirectory(): void
private function publishDataMigrationDirectory(): void
{
$this->publishes([
__DIR__.'/../assets/data-migrations' => database_path('data-migrations'),
], 'data-migrations');
}

/**
* Publish migrations directory.
*
* @return void
*/
private function publishMigrationDirectory(): void
{
$this->publishes([
__DIR__.'/../assets/database/migrations' => database_path('migrations'),
], 'data-migrations');
}

/**
* Register configuration file.
*
* @return void
*/
private function registerConfig(): void
private function publishConfig(): void
{

$this->publishes([
__DIR__.'/../assets/config/data-migrations.php' => config_path('data-migrations.php'),
], 'data-migrations');
}

/**
* Register artisan commands.
*
* @return void
*/
private function registerArtisanCommands(): void
{
$this->commands([
Expand Down

0 comments on commit 7e06e56

Please sign in to comment.