public function getTagsByTag() { $data['tags'] = null; $type = Input::get('type'); if ($type == null) { return null; } try { $tag = Input::get('tag'); if ($type == 1) { $data['tags'] = HashTag::join('hash_tagged_posts', 'hashtags.id', '=', 'hash_tagged_posts.tag_id')->whereIn('hash_tagged_posts.post_id', function ($query) { $query->select('posts.id')->from('posts')->whereType('1'); })->where('hashtags.tag', 'like', '%' . $tag . '%')->groupBy(['hashtags.id', 'hashtags.tag'])->get(['hashtags.id', 'hashtags.tag']); } elseif ($type == 2) { $data['tags'] = HashTag::join('hash_tagged_posts', 'hashtags.id', '=', 'hash_tagged_posts.tag_id')->whereIn('hash_tagged_posts.post_id', function ($query) { $query->select('posts.id')->from('posts')->whereType('2')->whereCampusId(Session::get('campus')); })->where('hashtags.tag', 'like', '%' . $tag . '%')->groupBy(['hashtags.id', 'hashtags.tag'])->get(['hashtags.id', 'hashtags.tag']); } if ($type == 3) { $data['tags'] = HashTag::join('hash_tagged_posts', 'hashtags.id', '=', 'hash_tagged_posts.tag_id')->whereIn('hash_tagged_posts.post_id', function ($query) { $query->select('posts.id')->from('posts')->whereType('3'); })->where('hashtags.tag', 'like', '%' . $tag . '%')->groupBy(['hashtags.id', 'hashtags.tag'])->get(['hashtags.id', 'hashtags.tag']); } } catch (Exception $e) { } return json_encode($data); }
public function testgetAndSetText() { $this->hashTag->setText('#thephpleague'); $this->assertEquals('#thephpleague', $this->hashTag->getText()); }