在Laravel 5.5中遇到“无效的日期时间格式”问题

时间:2019-03-07 19:03:03

标签: laravel datepicker

我正在做一个需要有付款日期的订单付款应用程序。但是当我运行测试时,我收到一条错误消息,提示“无效的dateTime格式。

我还尝试将YYYY-MM-DD更改为Y-m-d H:i:s

我以此迁移表格,

Schema::create('order_payments', function (Blueprint $table) {
$table->engine = 'MyISAM';
$table->increments('id');
$table->integer('order_id')->unsigned();
$table->integer('company_id')->unsigned();
$table->integer('currency_id')->unsigned();
$table->dateTime('payment_date')->nullable()->default(null);
$table->decimal('amount',13,2)->nullable()->default(null);
$table->timestamps();
}

那我的datePicker是

<div class="form-group">
<label>Date of payment (click the field below)</label> 
{{ Form::text('payment_date', null, array('class' => 'form-control input-lg datepicker','id' => 'datepicker')) }}
<script type="text/javascript">
$(function () {
$( "#datepicker" ).datepicker({
format: "Y-m-d H:i:s",
weekStart: 0,
calendarWeeks: true,
autoclose: true,
todayHighlight: true,
rtl: false,
orientation: "auto"
});
});
</script>
</div>

这是我的商店功能

public function store(Request $request)
{
    $orderpayments = Orderpayments::create($request->only(
        'order_id',
        'company_id',
        'currency_id',
        'bank',
        'type',
        'payment_date',
        'amount',
        'rate',
        'bank',
        'page',
        'number',
        'booklet_number',
        'voucher_num',
        'notes',
        'user_id'
    ));
    if ($request){
        Session::flash('message','Purchase order was successfully added');
        Session::flash('m-class','alert-success');
    } else {
        Session::flash('message','Data is not saved');
        Session::flash('m-class','alert-danger');
        return redirect()->route('orders.index');
    }
    return redirect()->route('orders.index');
}

这是错误

enter image description here

您认为问题出在哪里?

0 个答案:

没有答案