Response::view PHP Method

view() public static method

Return a new view response from the application.
public static view ( string $view, array $data = [], integer $status = 200, array $headers = [] ) : Illuminate\Http\Response
$view string
$data array
$status integer
$headers array
return Illuminate\Http\Response
        public static function view($view, $data = array(), $status = 200, $headers = array())
        {
            return \Illuminate\Routing\ResponseFactory::view($view, $data, $status, $headers);
        }

Usage Example

Beispiel #1
0
 public function showUser($screen_name)
 {
     if (User::where('screen_name', '=', $screen_name)->first() == NULL) {
         return Response::view('404', array('title' => '404 page'), 404);
     }
     $category_names = array('ent' => 'エンターテイメント', 'music' => '音楽', 'sing' => '歌ってみた', 'play' => '演奏してみた', 'dance' => '踊ってみた', 'vocaloid' => 'VOCALOID', 'nicoindies' => 'ニコニコインディーズ', 'animal' => '動物', 'cooking' => '料理', 'nature' => '自然', 'travel' => '旅行', 'sport' => 'スポーツ', 'lecture' => 'ニコニコ動画講座', 'drive' => '車載動画', 'history' => '歴史', 'politics' => '政治', 'science' => '科学', 'tech' => 'ニコニコ技術部', 'handcraft' => 'ニコニコ手芸部', 'make' => '作ってみた', 'anime' => 'アニメ', 'game' => 'ゲーム', 'toho' => '東方', 'imas' => 'アイドルマスター', 'radio' => 'ラジオ', 'draw' => '描いてみた', 'are' => '例のアレ', 'diary' => '日記', 'other' => 'その他', 'r18' => 'R-18', 'original' => 'オリジナル', 'portrait' => '似顔絵', 'character' => 'キャラクター');
     $user = User::where('screen_name', '=', $screen_name)->first();
     $star_items = $this->getStars($screen_name);
     try {
         $items = Item::where('user_id', '=', $user->id)->orderby('created_at', 'desc')->take(10)->get();
         foreach ($items as &$item) {
             $item['user'] = User::where('id', '=', $item->user_id)->get()[0];
             $item['star_count'] = Starmap::where('item_id', '=', $item->id)->count();
             $item['comment_count'] = Comment::where('item_id', '=', $item->id)->count();
             if ($item->category_id != 0) {
                 $item['category'] = Category::where('id', '=', $item->category_id)->get()[0]->content;
             }
         }
         $works = Work::where('user_id', '=', $user->id)->orderby('created_at', 'desc')->take(10)->get();
         foreach ($works as &$work) {
             $item = Item::where('id', '=', $work->item_id)->get()[0];
             $work['item'] = $item;
             $work['user'] = User::where('id', '=', $work->user_id)->get()[0];
             $work['item']['user'] = User::where('id', '=', $work->item->user_id)->get()[0];
             if ($item->category_id) {
                 $work['item_category'] = Category::where('id', '=', $item->category_id)->get()[0]->content;
             }
         }
         $twitter_profile = array('user' => $user, 'items' => $items, 'title' => $screen_name, 'stars' => $star_items, 'works' => $works, 'categories' => $category_names, 'star_count' => Starmap::where('user_id', '=', $user->id)->count(), 'work_count' => Work::where('user_id', '=', $user->id)->count());
         return View::make('user', $twitter_profile);
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
All Usage Examples Of Response::view