Faizi
Faizi

Reputation: 109

Laravel - Get checkbox value & update the database

I am beginner in laravel and working on a room booking system. I have added the toggle button in each room list for Availability and Booking. Now, i want to get the checkbox value and save them in database. enter image description here

<td>
    <label class="custom-toggle">
        <input type="checkbox" name="availability" id="availability">
        <span class="custom-toggle-slider rounded-circle"></span>
    </label>
</td>

I have availability column in rooms table. I want to save the Available and Booked value in db using ajax or any best method.

Upvotes: 1

Views: 863

Answers (1)

Ak-Wahid
Ak-Wahid

Reputation: 67

I can help you with that.

  1. I think you can use ajax method as you are using toggle.
  2. know used onclick="roomTest('{{$id}}')"

    <input type="checkbox" name="availability" id="availability" onclick="roomTest('{{$id}}')">

    • here $id is a room id.
  3. now make a function for roomTest() in your js file.
  4. I think you know laravel code and js for futher.
  5. All Set enjoy Code (Please feel free if any other detail you want)

Upvotes: 2

Related Questions