app/Http/Controllers/MicropostsController.php
/**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
Display a listing of the resource.
@return \Illuminate\Http\Response
Display a listing of the resource . @return \ Illuminate \ Http \ Response
public function index()
    {
        $data = [];
        if (\Auth::check()) {
            $user = \Auth::user();
            $microposts = $user->feed_microposts()->orderBy('created_at', 'desc')->paginate(10);
            $data = [
                'user' => $user,
                'microposts' => $microposts,
            ];
            $data += $this->counts($user);
            return view('users.show', $data);
        }else {
            return view('welcome');
        }
    }
public function index ( ) { $ data = [ ] ; if ( \ Auth :: check ( ) ) { $ user = \ Auth :: user ( ) ; $ microposts = $ user -> feed_microposts ( ) -> orderBy ( 'created_at' , 'desc' ) -> paginate ( 10 ) ; $ data = [ 'user' => $ user , 'microposts' => $ microposts , ] ; $ data += $ this -> counts ( $ user ) ; return view ( 'users.show' , $ data ) ; } else { return view ( 'welcome' ) ; } }
Display a listing of the resource.
Display a listing of the resource .
//↓micropostの数を View で表示するために、countを使用している