mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-01-29 11:08:53 +01:00
Better validation
This commit is contained in:
parent
e994f2a88a
commit
325ed033ba
@ -45,8 +45,12 @@
|
||||
$component = new Component(Input::all());
|
||||
$component->user_id = $this->auth->user()->id;
|
||||
if ($component->isValid()) {
|
||||
$component->saveOrFail();
|
||||
return $component;
|
||||
try {
|
||||
$component->saveOrFail();
|
||||
return $component;
|
||||
} catch (Exception $e) {
|
||||
App::abort(500, $e->getMessage());
|
||||
}
|
||||
} else {
|
||||
App::abort(404, $component->getErrors()->first());
|
||||
}
|
||||
@ -85,8 +89,17 @@
|
||||
$incident = new Incident(Input::all());
|
||||
$incident->user_id = $this->auth->user()->id;
|
||||
if ($incident->isValid()) {
|
||||
$incident->saveOrFail();
|
||||
return $incident;
|
||||
try {
|
||||
$component = $incident->parent;
|
||||
if (!$component) {
|
||||
App::abort(400, 'Invalid component specified');
|
||||
}
|
||||
|
||||
$incident->saveOrFail();
|
||||
return $incident;
|
||||
} catch (Exception $e) {
|
||||
App::abort(500, $e->getMessage());
|
||||
}
|
||||
} else {
|
||||
App::abort(404, $incident->getErrors()->first());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user