FareedR
3 months ago
192
5
Laravel

How can I take all value in checkbox array ?

Posted 3 months ago by FareedR

I'm getting this error because the value doesnt have default value " Undefined offset : 1 " . How can I take uncheck checkbox value ?

// blade 
<div class="col-3 mt-2">
    <div class="checkbox checkbox-danger-custom">
          <input id="contradict" type="checkbox" name="contradict[]" value="1">
           <label for="contradict">Contradict</label>
     </div>
</div>

// controller
$contradicts    = $request->get('contradict');

        foreach($contradicts as $contradict){
            if(!$request->has('contradict')){
                $request->merge(['contradict' => 0]);
            }

        }

already try this method . still error given . 

Please sign in or create an account to participate in this conversation.