Push changes that support creations of service packs and basic listing

This commit is contained in:
Dane Everitt 2016-11-15 20:20:32 -05:00
parent 1f47eda3b3
commit a1bc6fa2d3
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
15 changed files with 654 additions and 49 deletions

View file

@ -101,6 +101,8 @@ class Service
DB::beginTransaction();
try {
Storage::deleteDirectory('services/' . $service->file);
Models\ServiceVariables::whereIn('option_id', $options->get()->toArray())->delete();
$options->delete();
$service->delete();
@ -128,23 +130,10 @@ class Service
$filepath = 'services/' . $service->file . '/' . $filename;
$backup = 'services/.bak/' . str_random(12) . '.bak';
DB::beginTransaction();
try {
Storage::move($filepath, $backup);
Storage::put($filepath, $data['contents']);
$checksum = Models\Checksum::firstOrNew([
'service' => $service->id,
'filename' => $filename
]);
$checksum->checksum = sha1_file(storage_path('app/' . $filepath));
$checksum->save();
DB::commit();
} catch(\Exception $ex) {
DB::rollback();
Storage::move($backup, $filepath);
throw $ex;
}