Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

153
Views
vlaue of checkbox to database in vue laravel

i have this input:

<div class="d-flex justify-content-between align-items-center">
<label for="patymentTerms">Payment Terms</label>
<b-form-checkbox id="patymentTerms" :checked="true" switch v-model="rForm.payment_terms" />
</div>

and this is the data:

data() {
return {
  rForm: {
    payment_terms: "",
  },
};

},

i am able to store data and other inputs in database but i'm a bit confused of how can i return false or true to of this input

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

You can do it like this:

data() {
   return {
     rForm: {
        payment_terms: 0,
      },
    };

on on your controller:

$payment_terms = $request->payment_terms == 1 ? 1 : 0;
about 4 years ago · Juan Pablo Isaza Report

0

You can simply achieve this by using only v-model.

Demo :

new Vue({
  el: "#app",
  data() {
    return {
      rForm: {
        payment_terms: false,
      }
    }
  },
  methods: {
    getCheckboxValue() {
        console.log(this.rForm.payment_terms);
    }
  }
});
<link type="text/css" rel="stylesheet" href="https://unpkg.com/bootstrap@4.5.3/dist/css/bootstrap.min.css" />
<script src="https://unpkg.com/vue@2.6.12/dist/vue.min.js"></script>
<script src="https://unpkg.com/bootstrap-vue@2.21.2/dist/bootstrap-vue.min.js"></script>


<div id="app">
  <label for="patymentTerms">Payment Terms</label>
  <b-form-checkbox v-model="rForm.payment_terms" @change="getCheckboxValue" />
</div>

about 4 years ago · Juan Pablo Isaza Report

0

SOLUTION:

I forgot to change the input to boolean in MySQL and Controller

so this solved my problem:

View:

payment_terms: Boolean,

Controller:

'payment_terms' => 'required|boolean',

Thanks everyone

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!