Пример #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 joinArticle()
 {
     if (!Sentry::check()) {
         return Response::json(array('errCode' => 10, 'message' => '请登录'));
     }
     $user = Sentry::getUser();
     // $user = User::find(1);
     //分页
     $per_page = Input::get('per_page');
     $page = Input::get('page');
     $article_joins = ArticleJoin::where('user_id', '=', $user->id)->orderBy('created_at', 'desc')->get();
     //总页数
     $total = ceil(count($article_joins) / $per_page);
     //参与话题
     $article_joins = StaticController::page($per_page, $page, $article_joins);
     if ($article_joins == false) {
         return Response::json(array('errCode' => 0, 'message' => '没有参与话题', 'articles' => array(), 'total' => 0));
     }
     //根据用户参与的话题取到官方话题
     $articles = array();
     foreach ($article_joins as $article_join) {
         $article = Article::where('id', '=', $article_join->article_id)->first();
         array_push($articles, $article);
     }
     //去掉重复值
     array_unique($articles);
     //取到每个话题的图片和首段文字
     foreach ($articles as $article) {
         $article_url = ArticlePart::where('article_id', '=', $article->id)->where('type', '=', 'url')->orderBy('id', 'asc')->first();
         if (isset($article_url)) {
             $article->img = StaticController::imageWH($article_url->content);
         }
         $article_text = ArticlePart::where('article_id', '=', $article->id)->where('type', '=', 'text')->orderBy('id', 'asc')->first();
         if (isset($article_text)) {
             $article->content = $article_text->content;
         }
     }
     return Response::json(array('errCode' => 0, 'message' => '返回参与话题的内容!', 'articles' => $articles, 'total' => $total));
 }
Пример #3
0
 public function detail()
 {
     //话题部分
     $article_id = Input::get('article_id');
     $article = Article::find($article_id);
     if (!isset($article)) {
         return Response::json(array('errCode' => 1, 'message' => '没有该话题!'));
     }
     $article_parts = ArticlePart::where('article_id', '=', $article_id)->orderBy('id', 'asc')->get();
     //获取话题内容
     foreach ($article_parts as $part) {
         if ($part->type == 'url') {
             $part->img = StaticController::imageWH($part->content);
         }
     }
     //参与话题部分
     $per_page = Input::get('per_page');
     $page = Input::get('page');
     $article_joins = DB::table('article_joins')->where('article_id', '=', $article_id)->get();
     //总页数
     $total = ceil(count($article_joins) / $per_page);
     //评论
     $article_joins = StaticController::page($per_page, $page, $article_joins);
     //是否喜欢
     $type = $this->isArticleLike($article_id);
     if (count($article_joins) != 0) {
         foreach ($article_joins as $article_join) {
             $user_id = $article_join->user_id;
             $user = User::find($user_id);
             //参与话题人
             $article_join->username = $user->username;
             //参与话题人昵称
             $article_join->avatar = $user->avatar;
             //头像
             $article_part = ArticleJoinPart::where('join_id', '=', $article_join->id)->where('type', '=', 'text')->first();
             // Log::info($article_part);
             // echo $article_part->content;
             $article_join->content = $article_part->content;
             //第一段内容
         }
     }
     if ($page == 1) {
         return Response::json(array('errCode' => 0, 'message' => '返回文章内容', 'article' => $article, 'article_parts' => $article_parts, 'article_joins' => $article_joins, 'total' => $total, 'type' => $type));
     }
     return Response::json(array('errCode' => 0, 'message' => '返回文章详细内容', 'article_joins' => $article_joins, 'total' => $total, 'type' => $type));
 }
Пример #4
0
 public function articleDetail()
 {
     //话题部分
     $article_id = Input::get('article_id');
     $article = Article::find($article_id);
     if (!isset($article)) {
         return Response::view('errors.missing');
     }
     $article_parts = ArticlePart::where('article_id', '=', $article_id)->orderBy('id', 'asc')->get();
     //获取话题内容
     $type = $this->isArticleLike($article_id);
     return View::make('pc.topic')->with(array('article' => $article, 'article_parts' => $article_parts, 'type' => $type));
 }
Пример #5
0
 public function run()
 {
     $i = 0;
     for ($i = 0; $i < 60; $i++) {
         ArticlePart::create(['article_id' => $i + 1, 'content' => '也许你有个暗恋许久的ta,就是不知道该如何开口,那么七夕情人节就是表白对好时机。有帮大家帮,送ta什么好呢?除某车话', 'type' => 'text']);
         ArticlePart::create(['article_id' => $i + 1, 'content' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.5.jpg', 'type' => 'url']);
         ArticlePart::create(['article_id' => $i + 1, 'content' => '也许你有个暗恋许久的ta,就是不知道该如何开口,那么七夕情人节就是表白对好时机。有帮大家帮,送ta什么好呢?除某车话', 'type' => 'text']);
         ArticlePart::create(['article_id' => $i + 1, 'content' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.5.jpg', 'type' => 'url']);
     }
     // ArticlePart::create([
     // 	'article_id' => 2,
     // 	'content' => '也许你有个暗恋许久的ta,就是不知道该如何开口,那么七夕情人节就是表白对好时机。有帮大家帮,送ta什么好呢?除某车话',
     // 	'type' => 'text'
     // ]);
     // ArticlePart::create([
     // 	'article_id' => 2,
     // 	'content' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.5.jpg',
     // 	'type' => 'url'
     // ]);
     // ArticlePart::create([
     // 	'article_id' => 2,
     // 	'content' => '也许你有个暗恋许久的ta,就是不知道该如何开口,那么七夕情人节就是表白对好时机。有帮大家帮,送ta什么好呢?除某车话',
     // 	'type' => 'text'
     // ]);
     // ArticlePart::create([
     // 	'article_id' => 2,
     // 	'content' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.5.jpg',
     // 	'type' => 'url'
     // ]);
     // ArticlePart::create([
     // 	'article_id' => 3,
     // 	'content' => '也许你有个暗恋许久的ta,就是不知道该如何开口,那么七夕情人节就是表白对好时机。有帮大家帮,送ta什么好呢?除某车话',
     // 	'type' => 'text'
     // ]);
     // ArticlePart::create([
     // 	'article_id' => 3,
     // 	'content' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.5.jpg',
     // 	'type' => 'url'
     // ]);
     // ArticlePart::create([
     // 	'article_id' => 3,
     // 	'content' => '也许你有个暗恋许久的ta,就是不知道该如何开口,那么七夕情人节就是表白对好时机。有帮大家帮,送ta什么好呢?除某车话',
     // 	'type' => 'text'
     // ]);
     // ArticlePart::create([
     // 	'article_id' => 3,
     // 	'content' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.5.jpg',
     // 	'type' => 'url'
     // ]);
     // ArticlePart::create([
     // 	'article_id' => 4,
     // 	'content' => '也许你有个暗恋许久的ta,就是不知道该如何开口,那么七夕情人节就是表白对好时机。有帮大家帮,送ta什么好呢?除某车话',
     // 	'type' => 'text'
     // ]);
     // ArticlePart::create([
     // 	'article_id' => 4,
     // 	'content' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.5.jpg',
     // 	'type' => 'url'
     // ]);
     // ArticlePart::create([
     // 	'article_id' => 4,
     // 	'content' => '也许你有个暗恋许久的ta,就是不知道该如何开口,那么七夕情人节就是表白对好时机。有帮大家帮,送ta什么好呢?除某车话',
     // 	'type' => 'text'
     // ]);
     // ArticlePart::create([
     // 	'article_id' => 4,
     // 	'content' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.5.jpg',
     // 	'type' => 'url'
     // ]);
     // ArticlePart::create([
     // 	'article_id' => 5,
     // 	'content' => '也许你有个暗恋许久的ta,就是不知道该如何开口,那么七夕情人节就是表白对好时机。有帮大家帮,送ta什么好呢?除某车话',
     // 	'type' => 'text'
     // ]);
     // ArticlePart::create([
     // 	'article_id' => 5,
     // 	'content' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.5.jpg',
     // 	'type' => 'url'
     // ]);
     // ArticlePart::create([
     // 	'article_id' => 5,
     // 	'content' => '也许你有个暗恋许久的ta,就是不知道该如何开口,那么七夕情人节就是表白对好时机。有帮大家帮,送ta什么好呢?除某车话',
     // 	'type' => 'text'
     // ]);
     // ArticlePart::create([
     // 	'article_id' => 5,
     // 	'content' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.5.jpg',
     // 	'type' => 'url'
     // ]);
     // ArticlePart::create([
     // 	'article_id' => 6,
     // 	'content' => '也许你有个暗恋许久的ta,就是不知道该如何开口,那么七夕情人节就是表白对好时机。有帮大家帮,送ta什么好呢?除某车话',
     // 	'type' => 'text'
     // ]);
     // ArticlePart::create([
     // 	'article_id' => 6,
     // 	'content' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.5.jpg',
     // 	'type' => 'url'
     // ]);
     // ArticlePart::create([
     // 	'article_id' => 6,
     // 	'content' => '也许你有个暗恋许久的ta,就是不知道该如何开口,那么七夕情人节就是表白对好时机。有帮大家帮,送ta什么好呢?除某车话',
     // 	'type' => 'text'
     // ]);
     // ArticlePart::create([
     // 	'article_id' => 6,
     // 	'content' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.5.jpg',
     // 	'type' => 'url'
     // ]);
     // ArticlePart::create([
     // 	'article_id' => 7,
     // 	'content' => '也许你有个暗恋许久的ta,就是不知道该如何开口,那么七夕情人节就是表白对好时机。有帮大家帮,送ta什么好呢?除某车话',
     // 	'type' => 'text'
     // ]);
     // ArticlePart::create([
     // 	'article_id' => 7,
     // 	'content' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.5.jpg',
     // 	'type' => 'url'
     // ]);
     // ArticlePart::create([
     // 	'article_id' => 7,
     // 	'content' => '也许你有个暗恋许久的ta,就是不知道该如何开口,那么七夕情人节就是表白对好时机。有帮大家帮,送ta什么好呢?除某车话',
     // 	'type' => 'text'
     // ]);
     // ArticlePart::create([
     // 	'article_id' => 7,
     // 	'content' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.5.jpg',
     // 	'type' => 'url'
     // ]);
     // ArticlePart::create([
     // 	'article_id' => 8,
     // 	'content' => '也许你有个暗恋许久的ta,就是不知道该如何开口,那么七夕情人节就是表白对好时机。有帮大家帮,送ta什么好呢?除某车话',
     // 	'type' => 'text'
     // ]);
     // ArticlePart::create([
     // 	'article_id' => 8,
     // 	'content' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.5.jpg',
     // 	'type' => 'url'
     // ]);
     // ArticlePart::create([
     // 	'article_id' => 8,
     // 	'content' => '也许你有个暗恋许久的ta,就是不知道该如何开口,那么七夕情人节就是表白对好时机。有帮大家帮,送ta什么好呢?除某车话',
     // 	'type' => 'text'
     // ]);
     // ArticlePart::create([
     // 	'article_id' => 8,
     // 	'content' => 'http://7xl6gj.com1.z0.glb.clouddn.com/19.5.jpg',
     // 	'type' => 'url'
     // ]);
 }