1. Run
1 php artisan make:model Answer –cmrf
One-time model, and the corresponding controller migration factory is created, and the controller configured to resource
2. Modify **** _ ** _ ** _ ****** _ create_answers_table.php:
1 <?php 2 3 use Illuminate\Database\Migrations\Migration; 4 use Illuminate\Database\Schema\Blueprint; 5 use Illuminate\Support\Facades\Schema; 6 7 class CreateAnswersTable extends Migration 8 { 9 /** 10 * Run the migrations. 11 * 12 * @return void 13 */ 14 public function up() 15 { 16 Schema::create('answers', Function (the Blueprint Table $) { . 17 $ the table-> bigIncrements (' ID '); 18 is $ the table-> unsignedBigInteger (' user_id ') -> index () -> Comment ( " answer which is user-created ") ; 19 $ table-> unsignedBigInteger ( ' question_id ') -> index () -> the Comment ( " the answer is which questions to answer "); 20 $ table-> text ( ' Content ') -> the Comment ( " answer specific content "); 21 is $ the table-> Integer ( ' votes_count ') -> default (0) -> Comment ("The total number of points praise "); 22 the table- $> Integer ( ' comments_count ') -> default (0) -> Comment ( " Replies "); 23 is $ the table-> String ( ' is_hidden ',. 8) -> default ( " F. ") -> Comment ( " answer whether the state is hidden, the default settings must be longer than 8 "); // 8 must be greater than the length of the default settings, or not assigned F., is hidden 24 $ the table-> String ( ' close_comment ') -> default ( ' F ') -> the comment ( " answers are turned off comments "); // default F represents no, that is not closed, if you need to close the set T 25 $ table-> softDeletes () -> the comment ( " support soft deleted "); 26 $table->timestamps(); 27 }); 28 } 29 30 /** 31 * Reverse the migrations. 32 * 33 * @return void 34 */ 35 public function down() 36 { 37 Schema::dropIfExists('answers'); 38 } 39 }