Save custom fields on subscribe
- added methods to get/set a specific custom field - added method to get all custom fields (and assign each custom field to the subscriber's instance) - fixed zIndex of form editor's toolbar (footer was positioned above, preventing click)
This commit is contained in:
@ -12,6 +12,33 @@ class SubscriberCustomField extends Model {
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
static function createOrUpdate($data = array()) {
|
||||
$custom_field = CustomField::findOne($data['custom_field_id'])->asArray();
|
||||
if($custom_field === false) return false;
|
||||
|
||||
if($custom_field['type'] === 'date') {
|
||||
if(is_array($data['value'])) {
|
||||
$day = (isset($data['value']['day']) ? : 1);
|
||||
$month = (isset($data['value']['month']) ? : 1);
|
||||
$year = (isset($data['value']['year']) ? : 1970);
|
||||
$data['value'] = mktime(0, 0, 0, $month, $day, $year);
|
||||
}
|
||||
}
|
||||
|
||||
$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();
|
||||
}
|
||||
|
||||
static function createMultiple($values) {
|
||||
$values = array_map('array_values', $values);
|
||||
return self::rawExecute(
|
||||
|
Reference in New Issue
Block a user