/** * Display a listing of the resource. * * @return Response */ public function index() { $posts = Post::getPostsByType('post'); $auth = new Auth(); //Adds user's name to obj foreach ($posts as $key => $result) { $posts[$key]->name = $auth::user()->name; } return view('posts.index', compact('posts')); }
/** * Display a listing of the resource. * * @return Response */ public function index() { //Returns an array of objects $blogs = Post::getPostsByType('blog'); $auth = new Auth(); //Adds user's name to obj foreach ($blogs as $key => $result) { $blogs[$key]->name = $auth::user()->name; } return view('blogs.index', compact('blogs')); }