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 answers table and resources

Our answers table will be very similar to the current questions table, only that it will have fewer columns. Our answers can also be voted, and an answer can be marked as the best answer either by a question's poser or an admin. To create our answers table and resources, we perform the following steps:

  1. First, let's create the database table. Run the following command in the terminal:
    php artisan migrate:make create_answers_table --table=answers --create
    
  2. Now, open the migration, which is created under app/database/migrations, and replace the up() function's contents with the following code:
    Schema::create('answers', function(Blueprint $table) { $table->increments('id'); //question's id $table->integer('questionID')->unsigned()->default(0); ...

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