使用laravel更新模式中的记录,而不是保存

I'm trying to update records in the mysql database with laravel through a bootstrap modal. Here's how I have collected data from the table of records,

<button class="site-button" data-toggle="modal" data-target=".edit-booking"  data-bookingid="{{ $records->id }}" data-firstname="{{ $records->firstname }}" data-lastname="{{ $records->lastname }}" data-roomtype="{{ $records->roomtype }}" data-checkin="{{ $records->checkin }}" data-checkout="{{ $records->checkout }}" data-adults="{{ $records->adults }}" data-children="{{ $records->children }}" data-email="{{ $records->email }}" data-phone="{{ $records->phone }}" data-payment="{{ $records->payment }}" data-additionals="{{ $records->additionals }}" data-address="{{ $records->address }}"><span class="fa fa-edit"> Edit</span></button> / <button class="site-button"><span class="fa fa-trash"> Delete</span></button>

My modal for editing,

<div class="modal-content">
        <div class="modal-header bg-secondry">
          <button type="button" class="close" data-dismiss="modal">&times;</button>
          <h4 class="modal-title text-black">Edit Booking</h4>
        </div>
        <div class="modal-body edit-modal-body">
          <div class="section-content">
          <!-- CONTACT FORM-->
          <div class="wt-box">
            <form class="contact-form" id="edit-form" action="{{route('booking.update',$records->id)}}" name="edit-form" method="post"> {{method_field('patch')}} {{csrf_field()}}
              <div class="contact-one p-a40 p-r150">
                <div class="form-group">
                  <input name="editbookingid" id="editbookingid" type="hidden" class="form-control" value="">
                </div>
                <div class="form-group">
                  <label for="edit_firstname">First Name</label>
                  <input name="edit_firstname" id="edit_firstname" type="text" required class="form-control">
                </div>
                <div class="form-group">
                  <label for="edit_lastname">Last Name</label>
                  <input name="edit_lastname" type="text" id="edit_lastname" required class="form-control">
                </div>
                <div class="form-group">
                  <label for="edit_email">Email</label>
                  <input name="edit_email" type="email" id="edit_email" class="form-control" required>
                </div>
                <div class="form-group">
                  <label for="edit_phone">Phone</label>
                  <input name="edit_phone" type="phone" id="edit_phone" class="form-control" required>
                </div>
                <div class="form-group">
                <label for="edit_address">Address</label>
                  <textarea name="edit_address" id="edit_address" rows="3" class="form-control " required></textarea>
                </div>
                <div class="form-group">
                  <label for="edit_roomtype">Room type</label>
                  <input name="edit_roomtype" id="edit_roomtype" type="text" class="form-control" required>
                </div>
                <div class="two-columns-row">
                  <div class="form-group two-columns">
                    <label for="edit_adults">Adults</label>
                    <input type="text" name="edit_adults" id="edit_adults" class="form-control" required>
                  </div>
                  <div class="form-group two-columns">
                    <label for="edit_children">Children</label>
                    <input type="text" name="edit_children" id="edit_children" class="form-control" required>
                  </div>
                </div>
                <div class="two-columns-row">
                  <div class="form-group two-columns">
                    <label for="edit_checkin">Check-in Date</label>
                    <input type="date" name="edit_checkin" id="edit_checkin" class="form-control" required>
                  </div>
                  <div class="form-group two-columns">
                    <label for="edit_check-out">Check-out Date</label>
                    <input type="date" name="edit_checkout" id="edit_checkout" class="form-control" required>
                  </div>
                </div>
                <div class="form-group">
                  <label for="edit_payment">Payment Method</label>
                  <input name="edit_payment" type="text" id="edit_payment" required class="form-control">
                </div>
                <div class="form-group">
                  <label for="edit_additionals">Additional Notes</label>
                  <textarea name="edit_additionals" rows="3" id="edit_additionals" class="form-control"></textarea>
                </div>
                <div class="modal-footer">
                  <button type="button" class="site-button black radius-no text-uppercase" data-dismiss="modal">Close</button>
                  <button type="submit" class="site-button black radius-no text-uppercase" name="edit_submit">Save Changes</button>
                </div>
              </div>
            </form>
          </div>
        </div>
        </div>
      </div>

Script used to fill the modal,

<script>
  /* For filling data in the edit modal */
  $('.edit-booking').on('show.bs.modal', function (event) {
    var button = $(event.relatedTarget)
    var recordid = button.data('bookingid')
    var firstname = button.data('firstname')
    var lastname = button.data('lastname')
    var roomtype = button.data('roomtype')
    var checkin = button.data('checkin') 
    var checkout = button.data('checkout')
    var adults = button.data('adults')
    var children = button.data('children')
    var email = button.data('email')
    var phone = button.data('phone')
    var payment = button.data('payment')
    var additionals = button.data('additionals')
    var address = button.data('address') 
    var modal = $(this)

    modal.find('.edit-modal-body #editbookingid').val(recordid);
    modal.find('.edit-modal-body #edit_firstname').val(firstname);
    modal.find('.edit-modal-body #edit_lastname').val(lastname);
    modal.find('.edit-modal-body #edit_roomtype').val(roomtype);
    modal.find('.edit-modal-body #edit_checkin').val(checkin);
    modal.find('.edit-modal-body #edit_checkout').val(checkout);
    modal.find('.edit-modal-body #edit_adults').val(adults);
    modal.find('.edit-modal-body #edit_children').val(children);
    modal.find('.edit-modal-body #edit_email').val(email);
    modal.find('.edit-modal-body #edit_phone').val(phone);
    modal.find('.edit-modal-body #edit_payment').val(payment);
    modal.find('.edit-modal-body #edit_additionals').val(additionals);
    modal.find('.edit-modal-body #edit_address').val(address);
  })
</script>

This is my update() in the controller,

public function update(Request $request, $id)
    {
        $an_update = Bookings::findOrFail($id);
        $an_update->update($request->all());
        return back();
    }

and this is the model,

class Bookings extends Model
{
    protected $fillable = ['firstname', 'lastname', 'email', 'phone', 'address', 'adults', 'children', 'checkin', 'checkout', 'additionals', 'roomtype', 'payment'];
}

After filling all the changes in the form, if I click "save changes", the page reloads but the record is not updated at all.

Looks to me the way you are assigning the values from the request is what is wonky. I haven't tested this personally yet, in a bit of a rush. Will come back and update this answer in a few hours. In the mean time, give this a try.

$an_update = Bookings::findOrFail($id);
$an_update->firstName = $request->input('customer_license_plate');
$ticket->save();

return back();

Do that for all your records fields, remember that back() will redirect the user back to the page they came from regardless of a success or fail. You may wish to consider additional logic to redirect to another page upon success (like a listing screen for example).

Reference: https://laravel.com/docs/5.5/eloquent#updates

$id is assigned from a route parameter, but your route is being defined in your form action prior to the modal being opened. You don't appear to be updating the booking ID of the route anywhere when you open the modal.

This means you're always updating the booking with an ID of $records->id, whatever that value is.