/** * Create a subscription * * @param array $subscription * @throws \Exception * @return $this */ private function create($subscription) { if (empty($subscription['content']) || empty($subscription['to_lead']) && empty($subscription['to_channel'])) { throw new \Exception('Cannot create subscription. A required field is missing!'); } // If this notification has already been created. Just find the notification if (!empty($subscription['unique_id'])) { $this->find($subscription['unique_id']); } // Create the notification if (is_null($this->current_message) || !$this->current_message) { $model = new Model(); $subscription['content'] = $model->parseWithoutSave($subscription['content']); $this->current_message = Message::firstOrCreate($subscription); } return $this; }
/** * Set tag the for the node * * @param $tag * @return $this */ public function taggedAs($tag) { $this->model->taggedAs($tag); return $this; }