diff --git a/app/Ship/Providers/EventServiceProvider.php b/app/Ship/Providers/EventServiceProvider.php index 9348a1c..8175f78 100755 --- a/app/Ship/Providers/EventServiceProvider.php +++ b/app/Ship/Providers/EventServiceProvider.php @@ -27,7 +27,14 @@ class EventServiceProvider extends AbstractEventServiceProvider */ public function boot() { - // + if (app()->environment('production')) { + Event::listen(\Illuminate\Console\Events\CommandStarting::class, function ($event) { + $blocked = ['migrate:fresh', 'migrate:refresh', 'migrate:reset', 'db:wipe', 'db:seed']; + if (in_array($event->command, $blocked)) { + throw new \RuntimeException("BLOCKED: {$event->command} is disabled in production."); + } + }); + } } /** diff --git a/routes/console.php b/routes/console.php index a948dd0..e05f4c9 100755 --- a/routes/console.php +++ b/routes/console.php @@ -1,7 +1,6 @@ comment(Inspiring::quote()); })->purpose('Display an inspiring quote'); - -if ('production' === App::environment()) { - Artisan::command('migrate:fresh', function () { - $this->comment('You are not allowed to do this in production.'); - })->describe('Override default command in production.'); -}