gpt4 book ai didi

javascript - 是否可以通过 Laravel Controller 将 JQuery datepicker 对象传递到数据库中?

转载 作者:行者123 更新时间:2023-12-02 21:35:18 24 4
gpt4 key购买 nike

我到处都看过,但真的不太确定这是否可能。

我有一个带有 altField 的内联日期选择器,我希望将所选日期插入到数据库中。传入$service_id、$service_name和$service_price。

我知道我做错了,因此我想在这里寻求一些建议。

这是我的一些 show.blade.php 内容

 <script>
$(function () {
$("#datepicker").datepicker({
// showOtherMonths: true,
// selectOtherMonths: true,
// numberOfMonths: 2,
firstDay: 1,
altField: "#dateofbooking",
altFormat: "yy-mm-dd",
minDate: 0,
maxDate: "+2W",
});
});


</script>

<div class="row">
<div class="col-sm-7 text-center">
<div id="datepicker" class="text-center"></div>

</div> <!-- col-sm-8 end -->
<div class="col-sm-1">
</div>
<div class="col-sm-4">
{!! Form::open(['action' => 'PagesController@storebooking', 'method' => 'POST']) !!}

<div class="form-group"></br>
<h3 class="text-center">Selected Service</h3>
<hr class="featurette-divider">
<h4 class="float-left">{{$service_name}}</h4>
<h4 class="float-right">£ {{$service_price}}</h4>
<br>
{{Form::hidden('service_id', $service_id, ['class' => 'form-control', 'placeholder' => 'Service ID'])}}
{{Form::hidden('service_name', $service_name, ['class' => 'form-control', 'placeholder' => 'Service Name'])}}
{{Form::hidden('service_price', $service_price, ['class' => 'form-control', 'placeholder' => 'Service Price'])}}
</div>
<div class="form-group"></br>
<h3>Selected Date:</h3>
<!-- This will be hidden -->
{{Form::text('dateofbooking', '', ['id' => 'dateofbooking', 'class' => 'form-control', 'placeholder' => 'Booking Date'])}}
</div>
{{Form::submit('Book Appointment', ['class' => 'submitbtn btn btn-primary btn-lg btn-block', 'style' => 'border-radius: 20px;'])}}
{!! Form::close() !!}
</div>
</div> <!-- col-sm-4 end -->
</div> <!-- div row end -->

@endsection

我用什么来存储信息

 public function storebooking(Request $request)
{
$services = new Service;
$bookings = new Booking;
$bookings->user_id = auth()->user()->id;
$bookings->username = auth()->user()->username;
$bookings->firstname = auth()->user()->firstname;
$bookings->surname = auth()->user()->surname;
$bookings->email = auth()->user()->email;


$bookings->service_id = $request->input('service_id');
$bookings->service_name = $request->input('service_name');
$bookings->service_price = $request->input('service_price');
// $booking->dateofbooking = $request->input('dateofbooking'); // Doesn't work

$bookings->save();
return redirect('history')->with('success', 'Appointment Booked');
}

最佳答案

感谢MGS帮助我排除故障并提出解决方案。

对于其他有任何问题的人,这解决了我的问题:

show.blade.php

{{Form::hidden('dateofbooking', '', ['id' => 'dateofbooking'])}}

并在函数 storebooking 中使用了它

$bookings->dateofbooking = $request->input('dateofbooking');

关于javascript - 是否可以通过 Laravel Controller 将 JQuery datepicker 对象传递到数据库中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60517103/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com