示例#1
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();
 }
示例#2
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;
 }
示例#3
0
文件: Tags.php 项目: huoybb/standard
 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();
     }
 }
示例#4
0
文件: Users.php 项目: huoybb/movie
 public function taglogs()
 {
     if (null == $this->taglogs) {
         $this->taglogs = Taggables::query()->leftJoin('Tags', 'Tags.id = Taggables.tag_id')->where('Taggables.user_id = :user:'******'user' => $this->id])->columns(['Taggables.*', 'Taggables.id', 'Taggables.user_id', 'Taggables.tag_id', 'Taggables.created_at', 'Taggables.taggable_type', 'Taggables.taggable_id', 'Tags.name AS tag_name'])->orderBy('Taggables.created_at DESC')->execute();
     }
     return $this->taglogs;
 }