コード例 #1
0
ファイル: RestCache.php プロジェクト: httvncoder/151722441
 public function getCacheBasic()
 {
     $data = get();
     $default = array('clear_cache' => 0);
     extract(array_merge($default, $data));
     $cache_id = 'dln_category';
     if (!empty($clear_cache)) {
         Cache::forget($cache_id);
     }
     if (!Cache::has($cache_id)) {
         $category = FbCategory::where('status', '=', true)->select(DB::raw('id, name, description'))->orderBy('name', 'ASC')->get()->toArray();
         Cache::put($cache_id, json_encode($category), DLN_CACHE_CATEGORY);
     } else {
         $category = json_decode(Cache::get($cache_id));
     }
     $cache_id = 'dln_pages';
     if (!empty($clear_cache)) {
         Cache::forget($cache_id);
     }
     if (!Cache::has($cache_id)) {
         $page = FbPage::where('status', '=', true)->select(DB::raw('id, name, fb_id, category_id, like_count, talking_about'))->orderBy('like_count', 'DESC')->get()->toArray();
         Cache::put($cache_id, json_encode($page), DLN_CACHE_PAGE);
     } else {
         $page = json_decode(Cache::get($cache_id));
     }
     $result = new \stdClass();
     $result->category = $category;
     $result->page = $page;
     return Response::json(array('status' => 'success', 'data' => $result), 200);
 }
コード例 #2
0
ファイル: RestCategory.php プロジェクト: httvncoder/151722441
 public function getCategoryList()
 {
     $data = get();
     $default = array('page' => 0, 'clear_cache' => 0);
     extract(array_merge($default, $data));
     $cache_id = 'dln_category';
     if (!empty($clear_cache)) {
         Cache::forget($cache_id);
     }
     $limit = DLN_LIMIT;
     $skip = (int) $page * $limit;
     if (!Cache::has($cache_id)) {
         $records = FbCategory::whereRaw('status = ?', array(true))->skip($skip)->take($limit)->get()->toArray();
         Cache::put($cache_id, json_encode($records), DLN_CACHE_LONG_MINUTE);
     } else {
         $records = json_decode(Cache::get($cache_id));
     }
     return Response::json(array('status' => 'success', 'data' => $records), 200);
 }
コード例 #3
0
ファイル: FbPage.php プロジェクト: httvncoder/151722441
 public function getCategoryOptions()
 {
     return FbCategory::getNameList();
 }
コード例 #4
0
 public function run()
 {
     $timestamp = \Carbon\Carbon::now()->toDateTimeString();
     FbCategory::insert([['name' => 'Hài vui', 'slug' => 'hai-vui', 'status' => 1, 'updated_at' => $timestamp, 'created_at' => $timestamp], ['name' => 'Girl xinh', 'slug' => 'girl-xinh', 'status' => 1, 'updated_at' => $timestamp, 'created_at' => $timestamp], ['name' => 'Tin tức', 'slug' => 'tin-tuc', 'status' => 1, 'updated_at' => $timestamp, 'created_at' => $timestamp], ['name' => 'Bóng đá', 'slug' => 'bong-da', 'status' => 1, 'updated_at' => $timestamp, 'created_at' => $timestamp]]);
     FbPage::insert([['fb_id' => '755038977864672', 'category_id' => 1, 'type' => 'page', 'status' => true, 'updated_at' => $timestamp, 'created_at' => $timestamp], ['fb_id' => '487998621317746', 'category_id' => 1, 'type' => 'page', 'status' => true, 'updated_at' => $timestamp, 'created_at' => $timestamp], ['fb_id' => '232665283585847', 'category_id' => 1, 'type' => 'page', 'status' => true, 'updated_at' => $timestamp, 'created_at' => $timestamp], ['fb_id' => '506318469450579', 'category_id' => 1, 'type' => 'page', 'status' => true, 'updated_at' => $timestamp, 'created_at' => $timestamp], ['fb_id' => '383923618322771', 'category_id' => 1, 'type' => 'page', 'status' => true, 'updated_at' => $timestamp, 'created_at' => $timestamp], ['fb_id' => '178077709031664', 'category_id' => 1, 'type' => 'page', 'status' => true, 'updated_at' => $timestamp, 'created_at' => $timestamp]]);
 }