예제 #1
0
 public function showWelcome()
 {
     $posters = Poster::where('daily_id', '=', 0)->get();
     $topics = Topic::where('topic_url', '!=', '')->orderBy('created_at', 'desc')->get();
     $daily = poster::where('daily_id', '=', 1)->get();
     foreach ($daily as $recommend) {
         $gift = Gift::find($recommend->info_url);
         $recommend->content = $gift->content;
         $recommend->scan_num = $gift->scan_num;
         $recommend->focus_num = $gift->focus_num;
     }
     foreach ($posters as $poster) {
         $poster->photo_url = StaticController::imageWH($poster->photo_url);
     }
     foreach ($topics as $topic) {
         $topic->topic_url = StaticController::imageWH($topic->topic_url);
     }
     foreach ($daily as $day) {
         $day->photo_url = StaticController::imageWH($day->photo_url);
     }
     if (Request::wantsJson()) {
         return Response::json(array('errCode' => 0, 'message' => '返回首页首页数据', 'posters' => $posters, 'topics' => $topics, 'recommendations' => $daily));
     }
     return View::make('index.home')->with(array('posters' => $posters, 'topics' => $topics, 'recommendations' => $daily));
 }
예제 #2
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));
 }
예제 #3
0
 public function spaceHome()
 {
     $user_id = Input::get('user_id');
     if ($user_id != null) {
         $user = User::find($user_id);
     } else {
         if (!Auth::check()) {
             return Redirect::back();
         }
         $user = Auth::user();
     }
     // dd($user_id);
     $albums = $user->hasManyAlbums()->get();
     $topics = $user->hasManyTopics()->get();
     // dd($albums);
     $pictureCount = array();
     $picture = array();
     $topicCommentCount = array();
     if ($albums != null) {
         foreach ($albums as $album) {
             $pictures = $album->hasManyPictures()->get();
             $pictureCount[$album['id']] = $pictures->count();
             $p = $pictures->toArray();
             if ($p != null) {
                 $picture[$album['id']] = $p[0]['picture'];
             } else {
                 $picture[$album['id']] = "http://7xk6xh.com1.z0.glb.clouddn.com/album_03.png";
             }
         }
     }
     if (count($topics) != 0) {
         foreach ($topics as $topic) {
             $topicCommentCount[$topic['id']] = $topic->hasManyTopicComments()->count();
         }
     }
     $albums = Album::where('user_id', '=', $user->id)->paginate(2);
     $topics = Topic::where('user_id', '=', $user->id)->paginate(2);
     $result = array('user' => $user, 'albums' => $albums, 'topics' => $topics, 'pictureCount' => $pictureCount, 'picture' => $picture, 'topicCommentCount' => $topicCommentCount, 'links' => $this->link());
     return View::make('userCenter.zone')->with($result);
 }
예제 #4
0
 public function forumId($id)
 {
     if (Topic::where('id', '=', $id)->count() > 0) {
         $topic = Topic::find($id);
         $topic->view = $topic->view + 1;
         $topic->save();
         if (Commit::where('topic_id', '=', $id)->count() > 0) {
             $commit = Commit::where('topic_id', '=', $id)->get();
         } else {
             $commit = array("無留言");
         }
         $writer = Student::find($topic->stu_id);
         $export[] = array("title" => urlencode(str_replace("\\'", "'", addslashes($topic->title))), "writer" => urlencode(str_replace("\\'", "'", addslashes($writer->nick))), "body" => urlencode(str_replace("\\'", "'", base64_encode($topic->body))), "file" => urlencode(str_replace("\\'", "'", addslashes($topic->file))), "date" => $topic->day, "view" => $topic->view);
         if ($commit[0] != "無留言") {
             for ($i = 0; $i < count($commit); $i++) {
                 $export[] = array("title" => "", "writer" => urlencode(str_replace("\\'", "'", addslashes(Student::find($commit[$i]->stu_id)->nick))), "body" => urlencode(str_replace("\\'", "'", base64_encode($commit[$i]->body))), "file" => " ", "date" => $commit[$i]->day);
             }
         }
     } else {
         $export[] = array("title" => " ", "writer" => " ", "body" => " ", "file" => " ", "day" => " ");
     }
     return urldecode(json_encode($export));
 }
예제 #5
0
파일: Topic.php 프로젝트: 6174/phphub
 /**
  * 边栏同一节点下的话题列表
  */
 public function getSameNodeTopics($limit = 8)
 {
     return Topic::where('node_id', '=', $this->node_id)->recent()->take($limit)->remember(10)->get();
 }
예제 #6
0
파일: Forum.php 프로젝트: raphaeljorge/tor
 /**
  * Compte le nombre de topic dans le forum
  *
  */
 public function getTopicCount($forumId)
 {
     $forum = Forum::find($forumId);
     return Topic::where('forum_id', '=', $forum->id)->count();
 }