wallet handling 2
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Database\Console\Migrations\MigrateCommand as BaseMigrateCommand;
|
||||
use Illuminate\Database\Migrations\Migrator;
|
||||
|
||||
class MigrateCommand extends BaseMigrateCommand
|
||||
{
|
||||
public function __construct(Migrator $migrator, Dispatcher $dispatcher)
|
||||
{
|
||||
parent::__construct($migrator, $dispatcher);
|
||||
}
|
||||
|
||||
/**
|
||||
* Never auto-load database/schema/*.sql — it DROP TABLEs and wipes production data
|
||||
* when the migrations table is empty. Use baseline_migrations.sql on existing DBs.
|
||||
*/
|
||||
protected function prepareDatabase()
|
||||
{
|
||||
if (! $this->migrator->repositoryExists()) {
|
||||
$this->call('migrate:install', array_filter([
|
||||
'--database' => $this->option('database'),
|
||||
]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use App\Console\Commands\MigrateCommand;
|
||||
use Illuminate\Contracts\Events\Dispatcher;
|
||||
use Illuminate\Database\MigrationServiceProvider;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class AppServiceProvider extends ServiceProvider
|
||||
@@ -23,6 +26,19 @@ class AppServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
if (! $this->app->runningInConsole()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->app->extend('command.migrate', function ($command, $app) {
|
||||
if (! $app->bound('migrator')) {
|
||||
(new MigrationServiceProvider($app))->register();
|
||||
}
|
||||
|
||||
return new MigrateCommand(
|
||||
$app->make('migrator'),
|
||||
$app->make(Dispatcher::class)
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user