/** * Create or update option db entry. * * @param array|string $key * @param mixed $value * @return void */ private function store($key, $value = null) { if ($this->has($key)) { $this->storage->update($key, $value); } else { $this->storage->create($key, $value); } // each time we add an item to the db we need to // to Clear cached version and regenerate it $this->cache->forget('weboap.options'); }
/** * */ public function log() { $ip = $this->ip->get(); if (!$this->ip->isValid($ip)) { return; } if ($this->has($ip)) { //ip already exist in db. $this->storage->increment($ip); } else { $geo = $this->geo->locate($ip); $country = array_key_exists('country_code', $geo) ? $geo['country_code'] : null; //ip doesnt exist in db $data = array('ip' => $ip, 'country' => $country, 'clicks' => 1, 'updated_at' => c::now(), 'created_at' => c::now()); $this->storage->create($data); } // Clear the database cache $this->cache->destroy('weboap.visitor'); }