Only validate the component relationship if we sent one through. Closes #157

This commit is contained in:
James Brooks
2014-12-31 14:12:25 +00:00
parent 3c9478cdc4
commit a02fbfd74c

View File

@@ -18,8 +18,11 @@ class EloquentIncidentRepository extends EloquentRepository implements IncidentR
{
$incident = new $this->model($array);
$incident->user_id = $user_id;
$this->validate($incident);
$this->validate($incident)->hasRelationship($incident, 'component');
if (isset($array['component_id'])) {
$incident->hasRelationship($incident, 'component');
}
$incident->saveOrFail();
@@ -30,8 +33,11 @@ class EloquentIncidentRepository extends EloquentRepository implements IncidentR
{
$incident = $this->model->findOrFail($id);
$incident->fill($array);
$this->validate($incident);
$this->validate($incident)->hasRelationship($incident, 'component');
if (isset($array['component_id'])) {
$incident->hasRelationship($incident, 'component');
}
$incident->update($array);