O'Reilly logo

Laravel Application Development Blueprints by Halil İbrahim Yılmaz, Arda Kılıçdağı

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating our questions list page

Now that we can create questions, it's time to fill our dummy index page with actual question data. To do this, open your MainController.php file under app/controllers, and alter the function getIndex() with the following code:

public function getIndex() {
  return View::make('qa.index')
    ->with('title','Hot Questions!')
    ->with('questions',Question::with('users','tags')->orderBy('id','desc')->paginate(2));
}

In this method, we loaded the same page, but we added two variables named title and questions. The title variable is the dynamic title of our application, and the questions variable holds the last two questions, with pagination. Instead of get(), if you use paginate($number), you can get a ready-to-use pagination ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required