gpt4 book ai didi

php - 我遇到错误 "InvalidArgumentException Trailing data "

转载 作者:行者123 更新时间:2023-11-29 15:21:24 25 4
gpt4 key购买 nike

嗨,我尝试了在 Google 上找到的所有内容,但没有任何效果,当我尝试在数据库中插入日期时,我总是出现错误跟踪数据。我希望有一个人可以帮助我。非常感谢,并对我的英语感到抱歉。

//这是我的模型位置

<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class Location extends Model
{
protected $table = 'location';

}

//这是我的迁移

<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class Location extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('location', function(Blueprint $table) {
$table->bigIncrements('id');
$table->date('start');
$table->date('end');
});
}

/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('location');
}
}

//这是我在 Controller 中存储日期的方法

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Location;
use Carbon\Carbon ;
public function storeDate(Request $request){

$location = new Location();

$start = Carbon::createFromFormat('m/d/y', $request->input("start"));
$end = Carbon::createFromFormat('m/d/y', $request->input("end"));

$location->start = $start;
$location->end = $end;

$location->save();

return redirect('/myCar');

}
}

我的表格

 <form class="form-inline" method="POST" action="/storedate">
@csrf
<div class="modal-body">
<label class="sr-only" for="inlineFormInputName2"></label>
<input type="text" class="form-control mb-2 mr-sm-2" id="inlineFormInputName2" placeholder="dd/mm/yyyy" value="20/04/2019" name="start">
<label class="sr-only" for="inlineFormInputGroupUsername2"></label>
<div class="input-group mb-2 mr-sm-2">
<input type="text" class="form-control" id="inlineFormInputGroupUsername2" placeholder="dd/mm/yyyy" value="20/04/2019" name="end">
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Send message</button>
</div>
</form>

最佳答案

没关系,我找到了。在m/d/y中,我的y需要大写:

m/d/Y

感谢您的支持!

关于php - 我遇到错误 "InvalidArgumentException Trailing data ",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59356061/

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