Exemplo n.º 1
0
 /**
  * Process all Topic's (items, payments, questions, orders)
  */
 private function _processTopic()
 {
     $notifications = new Notifications();
     $exist = $notifications->where('resource', '=', $this->topics->resource)->count();
     if ($exist) {
         return;
     }
     $classModel = ucfirst($this->topics->topic);
     if (isset($this->topics->resource)) {
         $topic = $this->getTopic();
         if ($topic) {
             if ($classModel == 'Orders') {
                 $topicModel = new Order($topic);
                 $this->topics->process = $topicModel->send();
                 //var_dump($this->topics->process);die;
             } else {
                 if ($classModel == 'Questions') {
                     $topicModel = new Question($topic);
                     $this->topics->process = $topicModel->send();
                     if ($this->topics->process == null) {
                         return;
                     }
                 } else {
                     if ($classModel == 'Items') {
                         $topicModel = new Item($topic);
                         $this->topics->process = $topicModel->send();
                     } else {
                         if ($classModel == 'Payments') {
                             $topicModel = new Payment();
                             $this->topics->process = $topicModel->send();
                         } else {
                             return;
                         }
                     }
                 }
             }
         } else {
             $this->topics->process = false;
         }
     } else {
         $this->topics->process = false;
     }
     $notifications->saveNotification($this->topics);
 }