refactoring createOrUpdate method of models

This commit is contained in:
Amine Ben hammou
2018-02-07 17:40:06 +00:00
parent a2270d6689
commit 91622f8cd9
11 changed files with 69 additions and 153 deletions

View File

@ -37,18 +37,10 @@ class SubscriberCustomField extends Model {
}
}
$relation = self::where('custom_field_id', $data['custom_field_id'])
->where('subscriber_id', $data['subscriber_id'])
->findOne();
if($relation === false) {
$relation = self::create();
$relation->hydrate($data);
} else {
$relation->set($data);
}
return $relation->save();
return parent::internalCreateOrUpdate($data, array(
'custom_field_id' => $data['custom_field_id'],
'subscriber_id' => $data['subscriber_id']
));
}
static function createMultiple($values) {