dimanche 28 juin 2020

Checkbox value in controller in laravel

I am trying to get all the payments that is been selected through the checkboxes and then update the value in the database by '1' which means its paid. But when I try to get the values of checkbox array I only get 1 data in the array and not all selected. Any help?

View

<form action="/paid/" method="post" enctype="multipart/form-data">   
        @csrf
     <td><input type="checkbox" name="checked[]" value=""></td>
     <td>  </td>
     <td>
         <input id="commission" type="text" class="form-control" name="commission" 
         value="" readonly  autocomplete="notes" style="width: 15%;" autofocus>
     </td>
                                        
     <td>  </td>
     <td> 
         @if($p->sellet_commission_paid == '0')
            <button type="submit" class="btn btn-default" style="background-color:red">
                <b><em>UNPAID</b></em>
            </button>
         @else
            <a href="#" class="btn btn-default" style="background-color:green"><b><em>PAID</b></em></a>
         @endif                                    
     <td>   
 </form>

Controller

$checked = $request->input('checked');
     //   $checkboxes = $request->checked;

   dd($checked);
   die();
    //    dd(checkboxes);



Aucun commentaire:

Enregistrer un commentaire