Skip to content

Commit 15ebb18

Browse files
committed
Update migrate:fresh command
- declare command attribute - matches laravel 11 which worked around dependency injection problem - update service override
1 parent e46ac69 commit 15ebb18

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

app/Console/Commands/MigrateFreshAllCommand.php

+2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@
66
namespace App\Console\Commands;
77

88
use Illuminate\Database\Console\Migrations\FreshCommand;
9+
use Symfony\Component\Console\Attribute\AsCommand;
910
use Symfony\Component\Console\Input\InputOption;
1011

12+
#[AsCommand(name: 'migrate:fresh')]
1113
class MigrateFreshAllCommand extends FreshCommand
1214
{
1315
public function handle()

app/Providers/MigrationServiceProvider.php

+6-11
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,14 @@
66
namespace App\Providers;
77

88
use App\Console\Commands\MigrateFreshAllCommand;
9-
use Illuminate\Support\ServiceProvider;
9+
use Illuminate\Database\Console\Migrations\FreshCommand;
10+
use Illuminate\Database\MigrationServiceProvider as BaseProvider;
1011

11-
class MigrationServiceProvider extends ServiceProvider
12+
class MigrationServiceProvider extends BaseProvider
1213
{
13-
/**
14-
* Register the service provider.
15-
*
16-
* @return void
17-
*/
18-
public function register()
14+
#[\Override]
15+
public function registerMigrateFreshCommand()
1916
{
20-
$this->app->extend('command.migrate.fresh', function () {
21-
return new MigrateFreshAllCommand();
22-
});
17+
$this->app->singleton(FreshCommand::class, MigrateFreshAllCommand::class);
2318
}
2419
}

config/app.php

+1
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@
178178

179179
'providers' => ServiceProvider::defaultProviders()->except([
180180
Illuminate\Cookie\CookieServiceProvider::class,
181+
Illuminate\Database\MigrationServiceProvider::class,
181182
Illuminate\Session\SessionServiceProvider::class,
182183
])->merge([
183184
App\Providers\AppServiceProvider::class,

0 commit comments

Comments
 (0)