public function getRefreshTagCount() { // Get tags $tags = Tag::where('crawl', '=', false)->take(self::$limit_crawl_tag_count)->get(); if (!$tags->count()) { // Reset crawl status for all tags Tag::all()->update(array('crawl' => false)); return Response::json(array('status' => 'error'), 500); } foreach ($tags as $tag) { if ($tag->id) { // Count ad for tag $count = DB::table('dlnlab_classified_ads_tags')->where('tag_id', '=', $tag->id)->count(); $tag->count = $count; $tag->crawl = true; $tag->save(); } } return Response::json(array('status' => 'success'), 200); }