Skip to content

Commit

Permalink
close #352 Fixed: Not running migrations on module install
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed May 22, 2018
1 parent b894daf commit 8242da8
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
24 changes: 22 additions & 2 deletions app/Http/Controllers/Modules/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Models\Module\ModuleHistory;
use App\Traits\Modules;
use Artisan;
use Module as LModule;
use Illuminate\Http\Request;

class Item extends Controller
Expand Down Expand Up @@ -147,8 +148,6 @@ public function install(Request $request)
$json = $this->installModule($path);

if ($json['success']) {
Artisan::call('module:install', ['alias' => $json['data']['alias'], 'company_id' => session('company_id')]);

$message = trans('modules.installed', ['module' => $json['data']['name']]);

flash($message)->success();
Expand Down Expand Up @@ -266,4 +265,25 @@ public function disable($alias)

return redirect('apps/' . $alias)->send();
}

/**
* Final actions post update.
*
* @param $alias
* @param $old
* @param $new
* @return Response
*/
public function post($alias)
{
Artisan::call('module:install', ['alias' => $alias, 'company_id' => session('company_id')]);

$module = LModule::findByAlias($alias);

$message = trans('modules.installed', ['module' => $module->get('name')]);

flash($message)->success();

return redirect('apps/' . $alias);
}
}
2 changes: 1 addition & 1 deletion app/Traits/Modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public function installModule($path)

return [
'success' => true,
'installed' => true,
'installed' => url("apps/post/" . $module->alias),
'errors' => false,
'data' => $data,
];
Expand Down
2 changes: 1 addition & 1 deletion app/Utilities/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public static function all()
$data['core'] = $version;
}
} else {
$module = Module::get($alias);
$module = Module::findByAlias($alias);

// Up-to-date
if (version_compare($module->get('version'), $version) == 0) {
Expand Down
2 changes: 1 addition & 1 deletion resources/views/modules/item/show.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ function next() {
}
if (json['installed']) {
window.location = '{{ url("apps/" . $module->slug) }}';
window.location = json['installed'];
}
},
error: function(xhr, ajaxOptions, thrownError) {
Expand Down
1 change: 1 addition & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
Route::post('download', 'Modules\Item@download');
Route::post('unzip', 'Modules\Item@unzip');
Route::post('install', 'Modules\Item@install');
Route::get('post/{alias}', 'Modules\Item@post');
Route::get('{alias}/uninstall', 'Modules\Item@uninstall');
Route::get('{alias}/enable', 'Modules\Item@enable');
Route::get('{alias}/disable', 'Modules\Item@disable');
Expand Down

0 comments on commit 8242da8

Please sign in to comment.