mardi 6 octobre 2020

how to update a checkbox value on update function on request based?

i written a very simple code to update value of checkbox but it update 1 in db on uncheck it doesnot update 0 if request is submit here is code

<div class="form-group">
    <label>If it is checked it means user can only create given customer order.</label>
    <input type="checkbox" id="js-switch" name="customer_itself" @if($ot->customer_itself == 1) checked @endif>
</div>

controller side

if ($request->has('customer_itself')) {
    if($ot->customer_itself == 1){
        $ot->customer_itself = 0;
    }else{
        $ot->customer_itself = 1;
    }
            

what mistake in it?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire