Akaunting/overrides/akaunting/module/Commands/InstallCommand.php

57 lines
1.2 KiB
PHP
Raw Normal View History

2017-11-01 16:43:42 +00:00
<?php
2019-11-16 07:21:14 +00:00
namespace Akaunting\Module\Commands;
2017-11-01 16:43:42 +00:00
2020-06-12 08:51:37 +00:00
use App\Abstracts\Commands\Module as Command;
2020-06-11 20:40:24 +00:00
use App\Events\Module\Installed;
2020-06-11 20:32:13 +00:00
use App\Models\Module\Module as Model;
2017-11-01 16:43:42 +00:00
2020-06-12 08:51:37 +00:00
class InstallCommand extends Command
2017-11-01 16:43:42 +00:00
{
/**
* The name and signature of the console command.
*
* @var string
*/
2020-02-03 15:57:31 +00:00
protected $signature = 'module:install {alias} {company} {locale=en-GB}';
2017-11-01 16:43:42 +00:00
/**
* The console command description.
*
* @var string
*/
protected $description = 'Install the specified module.';
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
2020-06-11 20:32:13 +00:00
$this->prepare();
2020-02-03 15:57:31 +00:00
2020-07-01 06:02:19 +00:00
if ($this->getModel()) {
$this->comment("Module [{$this->alias}] is already installed.");
return;
}
2020-06-11 20:32:13 +00:00
$this->changeRuntime();
2019-12-03 12:41:56 +00:00
2020-06-11 20:32:13 +00:00
// Create db
$this->model = Model::create([
'company_id' => $this->company_id,
'alias' => $this->alias,
2019-11-16 07:21:14 +00:00
'enabled' => '1',
2019-12-03 12:41:56 +00:00
]);
2020-06-11 20:32:13 +00:00
$this->createHistory('installed');
event(new Installed($this->alias, $this->company_id, $this->locale));
2017-11-02 09:07:15 +00:00
2020-06-11 20:32:13 +00:00
$this->revertRuntime();
2018-12-25 13:49:37 +00:00
2020-06-12 08:57:18 +00:00
$this->info("Module [{$this->alias}] installed!");
2017-11-01 16:43:42 +00:00
}
}