private function storeVisitedPages() { foreach ($this->excludeUrls as $pattern) { if (preg_match($pattern, Yii::$app->request->url) === 1) { return; } } /** * @var VisitedPage $pageModel */ $pageModel = Yii::$container->get($this->modelMap['VisitedPage']['class']); if (!method_exists($pageModel, 'findOrCreate')) { throw new Exception('In VisitedPage model must exists findOrCreate method'); } $page = $pageModel->findOrCreate(); /** * @var VisitorVisit $visit */ $visit = Yii::$container->get($this->modelMap['VisitorVisit']['class']); if (!method_exists($visit, 'createOrUpdate')) { throw new Exception('In VisitorVisit model must exists createOrUpdate method'); } $visit->createOrUpdate($this->visitor->getPrimaryKey(), $page->id, $this->onlineTime); }
/** * @return \yii\db\ActiveQuery */ public function getVisitors0() { return $this->hasMany(Visitor::className(), ['last_activity_visited_page_id' => 'id']); }
/** * @return \yii\db\ActiveQuery */ public function getVisitor() { return $this->hasOne(Visitor::className(), ['id' => 'visitor_id']); }