check if model exists

This commit is contained in:
denisdulici 2019-01-07 16:13:40 +03:00
parent a118d9eab8
commit 18e52494e3

View File

@ -146,13 +146,15 @@ class Updater
} else { } else {
// Get module instance // Get module instance
$module = Module::findByAlias($alias); $module = Module::findByAlias($alias);
$model = Model::where('alias', $alias)->first();
// Move all files/folders from temp path // Move all files/folders from temp path
if (!File::copyDirectory($temp_path, module_path($module->get('name')))) { if (!File::copyDirectory($temp_path, module_path($module->get('name')))) {
return false; return false;
} }
$model = Model::where('alias', $alias)->first();
if (!empty($model)) {
// Add history // Add history
ModelHistory::create([ ModelHistory::create([
'company_id' => session('company_id'), 'company_id' => session('company_id'),
@ -162,6 +164,7 @@ class Updater
'description' => trans('modules.history.updated', ['module' => $module->get('name')]), 'description' => trans('modules.history.updated', ['module' => $module->get('name')]),
]); ]);
} }
}
// Delete temp directory // Delete temp directory
File::deleteDirectory($temp_path); File::deleteDirectory($temp_path);