add support for deleting service option
This commit is contained in:
parent
1e9bf1c220
commit
dcfdb89e3c
4 changed files with 56 additions and 0 deletions
|
@ -73,6 +73,28 @@ class Option
|
|||
return $option->id;
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
$option = Models\ServiceOptions::findOrFail($id);
|
||||
$servers = Models\Server::where('option', $option->id)->get();
|
||||
|
||||
if (count($servers) !== 0) {
|
||||
throw new DisplayException('You cannot delete an option that has servers attached to it currently.');
|
||||
}
|
||||
|
||||
DB::beginTransaction();
|
||||
|
||||
try {
|
||||
Models\ServiceVariables::where('option_id', $option->id)->delete();
|
||||
$option->delete();
|
||||
|
||||
DB::commit();
|
||||
} catch (\Exception $ex) {
|
||||
DB::rollBack();
|
||||
throw $ex;
|
||||
}
|
||||
}
|
||||
|
||||
public function update($id, array $data)
|
||||
{
|
||||
$option = Models\ServiceOptions::findOrFail($id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue