Exemplo n.º 1
0
 public function getReminders($model)
 {
     $collection = lib('collection');
     if (!is_object($model)) {
         throw new Exception('The first argument must be a model.');
     }
     $db = $model->_db->db;
     $table = $model->_db->table;
     $id = $model->id;
     $rows = Model::Reminder()->where(['object_db', '=', (string) $db])->where(['object_table', '=', (string) $table])->where(['object_id', '=', (int) $id])->where(['when', '>=', time()])->exec();
     foreach ($rows as $row) {
         $item = [];
         $item['event_type'] = (string) $row['object_table'];
         $item['event_id'] = (string) $row['object_id'];
         $item['when'] = (int) $row['when'];
         $item['color'] = (string) $row['color'];
         $collection[] = $item;
     }
     if (!empty($collection)) {
         $collection->orderBy('when');
     }
     return $collection->toArray();
 }