コード例 #1
0
ファイル: HomePageController.php プロジェクト: Jv-Juven/gift
 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));
 }