示例#1
0
 public function home()
 {
     $scroll_imgs = ScrollImg::all();
     //话题
     $topics = Topic::where('topic_url', '!=', '')->orderBy('created_at', 'desc')->get();
     $topics = StaticController::page(12, 1, $topics);
     //每日推荐
     $daily = Poster::where('daily_id', '=', 1)->get();
     //每日推
     $daily = StaticController::page(16, 1, $daily);
     // $user = Sentry::findUserById(4);
     // Sentry::login($user,false);
     // Sentry::logout();
     if (Sentry::check()) {
         foreach ($daily as $recommend) {
             $gift = Gift::find($recommend->info_url);
             $recommend->title = $gift->title;
             $recommend->price = $gift->price;
             $recommend->taobao_url = $gift->taobao_url;
             $gift_focus = GiftFocus::where('gift_id', '=', $recommend->info_url)->where('user_id', '=', Sentry::getUser()->id)->first();
             /* 2015-09-16 hyy fix */
             if (isset($gift_focus)) {
                 $recommend->focus = 1;
             } else {
                 $recommend->focus = 0;
             }
         }
     } else {
         foreach ($daily as $recommend) {
             $gift = Gift::find($recommend->info_url);
             $recommend->title = $gift->title;
             $recommend->price = $gift->price;
             $recommend->taobao_url = $gift->taobao_url;
             $recommend->focus = 0;
         }
     }
     //精选话题
     $articles = DB::table('articles')->orderBy('focus_num', 'desc')->get();
     $articles = StaticController::page(12, 1, $articles);
     if ($articles) {
         foreach ($articles as $article) {
             $article_url = ArticlePart::where('article_id', '=', $article->id)->where('type', '=', 'url')->first();
             // dd($article_url->content);
             if (isset($article)) {
                 $article->url = $article_url->content;
             } else {
                 $article->url = null;
             }
         }
     }
     return View::make('pc.home')->with(array('topics' => $topics, 'gifts' => $daily, 'articles' => $articles, 'scroll_imgs' => $scroll_imgs));
 }
示例#2
0
 public function brefOffical()
 {
     if (!Sentry::check()) {
         return Response::json(array('errCode' => 10, 'message' => '请登录'));
     }
     $user = Sentry::getUser();
     // $user = User::find(5);
     $per_page = Input::get('per_page');
     $page = Input::get('page');
     $officals = OfficalUser::where('user_id', '=', $user->id)->where('is_delete', '=', 0)->get();
     //总页数
     $total = ceil(count($officals) / $per_page);
     //排序
     $officals = StaticController::arraySortByCreatedAt($officals->toArray());
     //分页
     $officals = StaticController::page($per_page, $page, $officals);
     //总页数
     return Response::json(array('errCode' => 0, 'message' => '返回官方简讯', 'officals' => $officals, 'total' => $total));
 }
示例#3
0
 public function selectByLabel()
 {
     $inputs = array('char_id' => Input::get('_char'), 'scene_id' => Input::get('scene'), 'object_id' => Input::get('object'), 'price_id' => Input::get('price'));
     // dd($inputs['object_id']);
     $per_page = Input::get('per_page');
     $page = Input::get('page');
     $inputs = array_filter($inputs);
     // dd(count($inputs));
     $query = null;
     // dd($inputs['price_id']);
     foreach ($inputs as $key => $value) {
         if ($query != null) {
             $query = $query->where($key, $value);
         } else {
             $query = Gift::where($key, $value);
         }
     }
     if ($query == null) {
         // dd(count($gifts));
         //标签没有的情况
         // $gifts = StaticController::gifts();
         $gifts = Gift::orderBy('created_at', 'desc')->get();
         $total = ceil(count($gifts) / $per_page);
         $gifts = StaticController::page($per_page, $page, $gifts);
         $gifts = $this->addGiftImg($gifts);
         return Response::json(array('errCode' => 0, 'message' => '没有筛选礼品,返回全部', 'gifts' => $gifts, 'total' => $total));
     }
     $gifts = $query->get();
     if (count($gifts) == 0) {
         // $gifts = StaticController::gifts();
         $gifts = Gift::orderBy('created_at', 'desc')->get();
         $total = ceil(count($gifts) / $per_page);
         $gifts = StaticController::page($per_page, $page, $gifts);
         $gifts = $this->addGiftImg($gifts);
         return Response::json(array('errCode' => 0, 'message' => '没有筛选礼品,返回全部', 'gifts' => $gifts, 'total' => $total));
     }
     $total = ceil(count($gifts) / $per_page);
     $gifts = StaticController::page($per_page, $page, $gifts);
     $gifts = $this->addGiftImg($gifts);
     return Response::json(array('errCode' => 0, 'message' => '返回搜索数据', 'gifts' => $gifts, 'total' => $total));
 }
示例#4
0
 public function giftAjax()
 {
     // if(!Sentry::check())
     // 	return Response::json(array('errCode'=>1, 'message'=>'请登录'));
     // $user = Sentry::getUser();
     $user = User::find(1);
     $per_page = Input::get('per_page');
     $page = Input::get('page');
     $gift_focus = DB::table('gift_focus')->where('user_id', '=', $user->id)->orderBy('created_at', 'desc')->get();
     //总页数
     $total = ceil(count($gift_focus) / $per_page);
     // dd($total);
     //喜欢的礼品
     $focus = StaticController::page($per_page, $page, $gift_focus);
     // dd(count($focus));
     $gifts = array();
     if ($focus) {
         foreach ($focus as $gift) {
             array_push($gifts, Gift::find($gift->gift_id));
         }
         foreach ($gifts as $candy) {
             $url = GiftPoster::where('gift_id', '=', $candy->id)->first()->url;
             $candy->img = StaticController::imageWH($url);
         }
     }
     return Response::json(array('errCode' => 0, 'message' => '返回用户喜欢的礼品', 'gifts' => $gifts, 'total' => $total));
 }
示例#5
0
 public function involve()
 {
     //参与话题内容
     $join_id = Input::get('join_id');
     $article_join = ArticleJoin::find($join_id);
     if (!isset($article_join)) {
         return Response::json(array('errCode' => 1, 'message' => '没有该参与话题内容!'));
     }
     $article_join_parts = ArticleJoinPart::where('join_id', '=', $join_id)->orderBy('id', 'asc')->get();
     foreach ($article_join_parts as $part) {
         if ($part->type == 'url') {
             $part->img = StaticController::imageWH($part->content);
         }
     }
     //评论内容
     $per_page = Input::get('per_page');
     $page = Input::get('page');
     $join_coms = ArticleJoinCom::where('join_id', '=', $join_id)->with(['replies' => function ($query) {
         $query->select('com_id', 'content', 'sender_id')->orderBy('id', 'asc');
     }, 'sender' => function ($query) {
         $query->select('id', 'username', 'avatar');
     }, 'replies.sender' => function ($query) {
         $query->select('id', 'username');
     }])->get();
     foreach ($join_coms as $join_com) {
         $user = $join_com->sender;
         $join_com->username = $user->username;
         $join_com->avatar = $user->avatar;
         $join_com->replys = $join_com->replies;
         if (count($join_com->replys) != 0) {
             foreach ($join_com->replys as $reply) {
                 // dd($reply);
                 $reply->reply_name = $reply->sender->username;
                 unset($reply->sender);
             }
         }
         unset($join_com->replies);
         unset($join_com->sender);
     }
     // //总页数
     $total = ceil(count($join_coms) / $per_page);
     // //文章
     $join_coms = StaticController::page($per_page, $page, $join_coms);
     // $join_coms = DB::table('article_join_coms')->where('join_id', '=', $join_id)->get();
     // //总页数
     // $total = ceil(count($join_coms)/$per_page);
     // //文章
     // $join_coms = StaticController::page($per_page,$page,$join_coms);
     // if( $join_coms )
     // {
     // 	foreach($join_coms as $join_com)
     // 	{
     // 		$join_com->username = User::find($join_com->sender_id)->username;
     // 		$join_com->avatar = User::find($join_com->sender_id)->avatar;
     // 		$join_com->replys = ArticleJoinReply::where('com_id', '=', $join_com->id)->orderBy('id','asc')->get();
     // 		if(count($join_com->replys)!=0)
     // 		{
     // 			foreach($join_com->replys as $reply)
     // 			{
     // 				$reply->reply_name = User::find($reply->sender_id)->username;
     // 			}
     // 		}
     // 	}
     // }
     //是否喜欢
     $type = $this->isJoinLike($join_id);
     if ($page == 1) {
         return Response::json(array('errCode' => 0, 'message' => '返回参与话题详情', 'article_join' => $article_join, 'article_join_parts' => $article_join_parts, 'join_coms' => $join_coms, 'total' => $total, 'type' => $type));
     } else {
         return Response::json(array('errCode' => 0, 'message' => '返回参与话题详情', 'join_coms' => $join_coms, 'total' => $total, 'type' => $type));
     }
 }