Created
August 27, 2020 15:40
-
-
Save introqt/aaff4ab9a1e8182bd48a7e45b8fa5a03 to your computer and use it in GitHub Desktop.
Artisan fresh command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types=1); | |
namespace App\Console\Commands; | |
use Illuminate\Console\Command; | |
/** | |
* Class Fresh | |
* | |
* @package App\Console\Commands | |
*/ | |
class Fresh extends Command | |
{ | |
/** | |
* The name and signature of the console command. | |
* | |
* @var string | |
*/ | |
protected $signature = 'fresh'; | |
/** | |
* The console command description. | |
* | |
* @var string | |
*/ | |
protected $description = 'Migrates & seeds core & modules'; | |
/** @var array */ | |
private const FIRST_ORDER_MODULES = [ | |
'Commerce', | |
'Home', | |
'Page', | |
'Product', | |
'Recommendation', | |
'Setting', | |
'User' | |
]; | |
/** | |
* Create a new command instance. | |
* | |
* @return void | |
*/ | |
public function __construct() | |
{ | |
parent::__construct(); | |
} | |
/** | |
* Execute the console command. | |
* | |
* @return mixed | |
*/ | |
public function handle(): void | |
{ | |
$this->call('migrate:fresh', [ | |
'--seed' => 1, | |
]); | |
$this->fillFirstOrderModules(); | |
$this->call('module:seed', ['Menu']); | |
} | |
/** | |
* Fill all besides Menu | |
*/ | |
private function fillFirstOrderModules(): void | |
{ | |
foreach (self::FIRST_ORDER_MODULES as $MODULE) { | |
$this->call("module:seed", [$MODULE]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment