Skip to content

Commit

Permalink
added module installed event
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed Nov 2, 2017
1 parent dfac921 commit c7f7d2f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
8 changes: 8 additions & 0 deletions app/Console/Commands/ModuleInstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Console\Commands;

use App\Events\ModuleInstalled;
use App\Models\Module\Module;
use App\Models\Module\ModuleHistory;
use Illuminate\Console\Command;
Expand Down Expand Up @@ -40,6 +41,7 @@ public function handle()

$module = LaravelModule::findByAlias($model->alias);

// Add history
$data = [
'company_id' => $this->argument('company_id'),
'module_id' => $model->id,
Expand All @@ -50,6 +52,12 @@ public function handle()

ModuleHistory::create($data);

// Update database
$this->call('migrate', ['--force' => true]);

// Trigger event
event(new ModuleInstalled($model->alias));

$this->info('Module installed!');
}
}
18 changes: 18 additions & 0 deletions app/Events/ModuleInstalled.php
Original file line number Diff line number Diff line change
@@ -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;
}
}
3 changes: 0 additions & 3 deletions app/Traits/Modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,6 @@ public function installModule($path)
File::copyDirectory($temp_path, $module_path);
File::deleteDirectory($temp_path);

// Update database
Artisan::call('migrate', ['--force' => true]);

Artisan::call('cache:clear');

$data = [
Expand Down

0 comments on commit c7f7d2f

Please sign in to comment.