Skip to content

Commit

Permalink
check if model exists
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed Jan 7, 2019
1 parent a118d9e commit 18e5249
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions app/Utilities/Updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,21 +146,24 @@ public static function fileCopy($alias, $temp_path, $version)
} else {
// Get module instance
$module = Module::findByAlias($alias);
$model = Model::where('alias', $alias)->first();

// Move all files/folders from temp path
if (!File::copyDirectory($temp_path, module_path($module->get('name')))) {
return false;
}

// Add history
ModelHistory::create([
'company_id' => session('company_id'),
'module_id' => $model->id,
'category' => $module->get('category'),
'version' => $version,
'description' => trans('modules.history.updated', ['module' => $module->get('name')]),
]);
$model = Model::where('alias', $alias)->first();

if (!empty($model)) {
// Add history
ModelHistory::create([
'company_id' => session('company_id'),
'module_id' => $model->id,
'category' => $module->get('category'),
'version' => $version,
'description' => trans('modules.history.updated', ['module' => $module->get('name')]),
]);
}
}

// Delete temp directory
Expand Down

0 comments on commit 18e5249

Please sign in to comment.