jeudi 4 avril 2019

How To Update Column Of A Table With Selected Value In Checkbox Form In Laravel?

This is my form in blade File : 1 and this is my form cods :

<form action="" method="post">
 <label for="No1"> No1 </label>
<input type="checkbox" name="name[]" id="No1" value="No1"><br>
 <label for="No2"> No2 </label>
<input type="checkbox" name="name[]" id="No2" value="No2"><br>
 <label for="No3"> No3 </label>
<input type="checkbox" name="name[]" id="No3" value="No3"><br>
 <label for="No4"> No4 </label>
<input type="checkbox" name="name[]" id="No4" value="No4"><br>
<input type="submit" value="Save">
</form>

I want to save multiple selection on check boxes in database column, For Example If i checked No2 & No3 I want to update this values in database to "enable".
At Php My Admin We can do this work by this code :
UPDATE tableName SET columnName='enable' WHERE Numbers IN ('No1','No2')
How can I do this sql query in laravel?

I should get checked value in form in an array and use them in Where IN clauses , but I don't Know how can i get checked values in an array and convert upper SQL query in laravel format.




Aucun commentaire:

Enregistrer un commentaire