How to set table with yes no checkbox to mysql using Laravel

please help me with this:
Using Laravel

  • Function/Purpose:

Guest (no register/login) – completed <have a login/Register – working>

  • Objective:

Survey Form with basic text field: fname, lname, ID Number, mobile and then 3 questions with yes and no checkbox.

  • My challenge:
    I dont know what to place for the 2options survey questions to migrate to DB?

hi Here is my migration create_survey_posts_table.php

use IlluminateDatabaseMigrationsMigration;
use IlluminateDatabaseSchemaBlueprint;
use IlluminateSupportFacadesSchema;

class CreateSurveyPostsTable extends Migration
     * Run the migrations.
     * @return void
    public function up()
        Schema::create('posts', function (Blueprint $table) {

     * Reverse the migrations.
     * @return void
    public function down()

what should i use for the sq-symptoms as it is a radio button yes and no options to upload (migrate) to mysql


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

       <input type="radio" name="sq-symptoms" value="yes">
      <label for="yes"></label>

=>if you select radio button your value will be store in database yes and if you not select radio button it is automatic value pass no.

if(isset($request->sq-symptoms)) {
            $post->sq-symptoms= $request->sq-symptoms;
            $post->sq-symptoms= 'no';

Method 2

A radio input with validation maybe?

  <label>Yes<input type="radio" name="sq_symptoms" value="Yes"></label>
  <label>No<input type="radio" name="sq_symptoms" value="No"></label>
// laravel validation
sq_symptoms: ['required', 'in:Yes,No']
// using the Rule facade
sq_symptoms: ['required', Rule::in(['Yes', 'No'])]

There are no for or id attributes needed in this example. To explain why, here’s an extract of MDN’s documentation on the <label> element:

To associate the <label> with an <input> element, you need to give the
<input> an id attribute. The <label> then needs a for attribute whose
value is the same as the input’s id.

Alternatively, you can nest the <input> directly inside the <label>,
in which case the for and id attributes are not needed because the
association is implicit:

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x