public function show($type, $alias, $id)
 {
     $chitiet = BaiViet::join('nguoi_dung', function ($join) {
         $join->on('nguoi_dung.id', '=', 'bai_viet.id_nguoi_dang');
     })->join('loai_bai_viet', function ($join) {
         $join->on('loai_bai_viet.id', '=', 'bai_viet.id_loai_bai_viet');
     })->select('nguoi_dung.ho_ten', 'bai_viet.id', 'bai_viet.thoi_gian_dang', 'bai_viet.thoi_gian_sua', 'bai_viet.tieu_de_bai_viet', 'loai_bai_viet.mo_ta_loai_bai_viet', 'bai_viet.tom_tat_bai_viet', 'bai_viet.noi_dung_bai_viet', 'loai_bai_viet.alias', 'bai_viet.tags')->where("bai_viet.trang_thai_bai_viet", 1)->where('bai_viet.id', $id, 'and')->where('loai_bai_viet.nhom_loai', $type, 'and')->where('loai_bai_viet.alias', $alias)->orderBy('bai_viet.thu_tu_bai_viet', 'asc')->get();
     $tags = new QuanLyQuanLyBaiViet();
     $tags = $tags->convertToStringTags($chitiet[0]->tags);
     return View::make('nguoidung_baiviet.view')->with('chitiet', $chitiet)->with('title', 'Chi tiết bài viết')->with('tags', $tags);
 }
 public function getIdThreads($array_id_tags)
 {
     $all_id_threads = BaiViet::select('id', 'tags')->where('tags', '!=', '')->get();
     $result_id = array();
     $index = 0;
     foreach ($all_id_threads as $thread) {
         $array_id_tags_thread = explode(',', $thread->tags);
         foreach ($array_id_tags_thread as $key => $value) {
             if (array_search($value, $array_id_tags)) {
                 $result_id[$index++] = $thread->id;
             }
         }
     }
     return array_unique($result_id);
 }