public function controlledResource() { if ($this->request->method === 'POST' || $this->request->method === 'OPTIONS' || $this->request->uri === '/votes') { return When::resolve(array()); } $search = (array) $this->request->query['search']; $options = (array) $this->request->query['options']; if (isset($search['created-min']) && isset($search['created-max'])) { $search = array('$and' => array(array('created' => array('$gte' => new DateTime($search['created-min']))), array('created' => array('$lte' => new DateTime($search['created-max']))))); } $this->response->headers['X-Count'] = Model::count($search, array(), $this->domain); return Model::fetch($search, $options, $this->domain); }