refactoring createOrUpdate method of models
This commit is contained in:
@ -109,20 +109,6 @@ class Form extends Model {
|
||||
}
|
||||
|
||||
static function createOrUpdate($data = array()) {
|
||||
$form = false;
|
||||
|
||||
if(isset($data['id']) && (int)$data['id'] > 0) {
|
||||
$form = self::findOne((int)$data['id']);
|
||||
}
|
||||
|
||||
if($form === false) {
|
||||
$form = self::create();
|
||||
$form->hydrate($data);
|
||||
} else {
|
||||
unset($data['id']);
|
||||
$form->set($data);
|
||||
}
|
||||
|
||||
return $form->save();
|
||||
return parent::internalCreateOrUpdate($data);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user