added module installed event

This commit is contained in:
denisdulici 2017-11-02 12:07:15 +03:00
parent dfac921e97
commit c7f7d2fdfc
3 changed files with 26 additions and 3 deletions

View File

@ -2,6 +2,7 @@
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Events\ModuleInstalled;
use App\Models\Module\Module; use App\Models\Module\Module;
use App\Models\Module\ModuleHistory; use App\Models\Module\ModuleHistory;
use Illuminate\Console\Command; use Illuminate\Console\Command;
@ -40,6 +41,7 @@ class ModuleInstall extends Command
$module = LaravelModule::findByAlias($model->alias); $module = LaravelModule::findByAlias($model->alias);
// Add history
$data = [ $data = [
'company_id' => $this->argument('company_id'), 'company_id' => $this->argument('company_id'),
'module_id' => $model->id, 'module_id' => $model->id,
@ -50,6 +52,12 @@ class ModuleInstall extends Command
ModuleHistory::create($data); ModuleHistory::create($data);
// Update database
$this->call('migrate', ['--force' => true]);
// Trigger event
event(new ModuleInstalled($model->alias));
$this->info('Module installed!'); $this->info('Module installed!');
} }
} }

View File

@ -0,0 +1,18 @@
<?php
namespace App\Events;
class ModuleInstalled
{
public $alias;
/**
* Create a new event instance.
*
* @param $alias
*/
public function __construct($alias)
{
$this->alias = $alias;
}
}

View File

@ -201,9 +201,6 @@ trait Modules
File::copyDirectory($temp_path, $module_path); File::copyDirectory($temp_path, $module_path);
File::deleteDirectory($temp_path); File::deleteDirectory($temp_path);
// Update database
Artisan::call('migrate', ['--force' => true]);
Artisan::call('cache:clear'); Artisan::call('cache:clear');
$data = [ $data = [