Ejemplo n.º 1
0
 public function removeTags($tags)
 {
     if (empty($tags)) {
         return;
     }
     $updateTag = Tag::findOne(['name' => $tags]);
     foreach ($tags as $name) {
         $updateTag = Tag::findOne(['name' => $name]);
         if (!empty($updateTag)) {
             $updateTag->updateCounters(['frequency' => -1]);
         }
     }
     Tag::deleteAll(['frequency' => '<=0']);
 }
Ejemplo n.º 2
0
 /**
  * Finds the Tag model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Tag the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Tag::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }