added module:install command
This commit is contained in:
parent
ae15ad1397
commit
cfbd5eba59
55
app/Console/Commands/ModuleInstall.php
Normal file
55
app/Console/Commands/ModuleInstall.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Module\Module;
|
||||
use App\Models\Module\ModuleHistory;
|
||||
use Illuminate\Console\Command;
|
||||
use Module as LaravelModule;
|
||||
|
||||
class ModuleInstall extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'module:install {module} {company_id}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Install the specified module.';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$request = [
|
||||
'company_id' => $this->argument('company_id'),
|
||||
'alias' => strtolower($this->argument('module')),
|
||||
'status' => '1',
|
||||
];
|
||||
|
||||
$model = Module::create($request);
|
||||
|
||||
$module = LaravelModule::findByAlias($model->alias);
|
||||
|
||||
$data = [
|
||||
'company_id' => $this->argument('company_id'),
|
||||
'module_id' => $model->id,
|
||||
'category' => $module->get('category'),
|
||||
'version' => $module->get('version'),
|
||||
'description' => trans('modules.history.installed', ['module' => $module->get('name')]),
|
||||
];
|
||||
|
||||
ModuleHistory::create($data);
|
||||
|
||||
$this->info('Module installed!');
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ class Kernel extends ConsoleKernel
|
||||
Commands\CompanySeed::class,
|
||||
Commands\BillReminder::class,
|
||||
Commands\InvoiceReminder::class,
|
||||
Commands\ModuleInstall::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -10,8 +10,6 @@ use App\Models\Module\ModuleHistory;
|
||||
use App\Traits\Modules;
|
||||
use Illuminate\Routing\Route;
|
||||
|
||||
use Module as MModule;
|
||||
|
||||
class Item extends Controller
|
||||
{
|
||||
use Modules;
|
||||
@ -132,7 +130,7 @@ class Item extends Controller
|
||||
/**
|
||||
* Show the form for viewing the specified resource.
|
||||
*
|
||||
* @param $path
|
||||
* @param $request
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
@ -143,22 +141,7 @@ class Item extends Controller
|
||||
$json = $this->installModule($path);
|
||||
|
||||
if ($json['success']) {
|
||||
$request['company_id'] = session('company_id');
|
||||
$request['alias'] = $json['data']['alias'];
|
||||
|
||||
$module = Module::create($request->all());
|
||||
|
||||
$mmodule = MModule::findByAlias($module->alias);
|
||||
|
||||
$data = array(
|
||||
'company_id' => session('company_id'),
|
||||
'module_id' => $module->id,
|
||||
'category' => $mmodule->get('category'),
|
||||
'version' => $mmodule->get('version'),
|
||||
'description' => trans('modules.history.installed', ['module' => $mmodule->get('name')]),
|
||||
);
|
||||
|
||||
ModuleHistory::create($data);
|
||||
Artisan::call('module:install ' . $json['data']['alias'] . ' ' . session('company_id'));
|
||||
|
||||
$message = trans('messages.success.added', ['type' => trans('modules.installed', ['module' => $json['data']['name']])]);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user