Example #1
0
 public function deleteTagAction(Users $user, Taggables $tag)
 {
     if ($this->request->isPost()) {
         $tag->delete();
         return $this->redirectByRoute(['for' => 'users.showTags', 'user' => $user->id]);
     }
 }
Example #2
0
 public function deleteItemAction($tag, Taggables $taggable)
 {
     /** @var Files $file */
     $file = $taggable->getTagged();
     $file->deleteTag($taggable);
     return $this->redirectByRoute(['for' => 'tags.show', 'tag' => $tag]);
 }
 public function addComment($event, Taggables $taggable)
 {
     $tagged = $taggable->getTagged();
     if (property_exists($tagged, 'commentCount')) {
         $tagged->increaseCount('commentCount');
     }
     $taggable->tag()->save();
     //刷新一下时间戳updated_at
 }
Example #4
0
 /**
  * @param Tags $tag
  * @return myModel
  */
 public function getTaggable(Tags $tag, Users $user = null)
 {
     $query = Taggables::query()->where('tag_id = :tag:', ['tag' => $tag->id])->andWhere('taggable_type = :type:', ['type' => get_class($this)])->andWhere('taggable_id = :id:', ['id' => $this->id]);
     if ($user) {
         $query->andWhere('user_id = :user:'******'user' => $user->id]);
     }
     return $query->execute();
 }
Example #5
0
 public function deleteTag(Tags $tag = null)
 {
     $query = Taggables::query()->Where('taggable_id = :taggable_id:', ['taggable_id' => $this->id])->andWhere('taggable_type = :type:', ['type' => get_class($this)])->andWhere('user_id = :user:'******'user' => $this->getDI()->get('session')->auth['id']]);
     if ($tag) {
         $query = $query->andWhere('tag_id = :tag_id:', ['tag_id' => $tag->id]);
     }
     $taggables = $query->execute();
     foreach ($taggables as $taggable) {
         $taggable->delete();
     }
     return $this;
 }
Example #6
0
 public function deleteByCurrentUser()
 {
     $user = AuthFacade::getService();
     $taggables = Taggables::query()->where('tag_id = :tag:', ['tag' => $this->id])->andWhere('user_id = :user:'******'user' => $user->id])->execute();
     $taggables->delete();
     //        dd($taggables);
     $meta = $this->getTagmetaOrNew();
     //        dd($meta);
     $meta->delete();
     if ($taggables->count() == 0) {
         $this->delete();
     }
 }
Example #7
0
 public function getStatistics()
 {
     return ['comments' => Comments::count('user_id = "' . $this->id . '"'), 'tags' => Taggables::count('user_id = "' . $this->id . '"'), 'links' => Links::count('user_id = "' . $this->id . '"'), 'favorites' => Favorites::count('user_id = "' . $this->id . '"')];
 }
Example #8
0
 public function deleteTagAction(Movies $movie, Taggables $taggable)
 {
     $taggable->delete();
     return $this->redirectByRoute(['for' => 'movies.showTags', 'movie' => $movie->id]);
 }