/** * @param array $options * @return array|bool */ public static function addNotify($options = []) { if (isset($options['id'])) { $model = self::model()->findByPk((int) $options['id']); } else { $model = new self(); } if (isset($options['url'])) { $model->setUrl($options['url']); } if (isset($options['image'])) { $model->setImage($options['image']); } $model->setAttributes($options, false); if ($model->save()) { if (isset($options['read']) && (isset($options['user_id']) && (int) $options['user_id'] > 0)) { self::changeReadStatusById($model->id, $options['user_id'], $options['read']); } if (isset($options['id'])) { $model->onUpdateNotify($model); } else { $model->onAddNotify($model); } return true; } else { return $model->getErrors(); } }