我有错误“InvalidArgumentException 尾随数据”

我尝试了在 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');

    }

}

//这是我在控制器中存储日期的方法


<?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');


    }

}



Smart猫小萌
浏览 126回答 1
1回答

宝慕林4294392

没关系,我找到了。在m/d/y我的y中需要大写:月/日/年谢谢您的支持 !
打开App,查看更多内容
随时随地看视频慕课网APP