Php 在laravel 5.4上输入日期时出错

Php 在laravel 5.4上输入日期时出错,php,mysql,date,laravel-5,Php,Mysql,Date,Laravel 5,我正在使用Laravel创建项目,但在创建使用日期的表单时遇到了一些问题: 表或脚本中是否缺少某些内容? 这是桌子 这里是控制器 public function index(Request $request){ $data = array(); if($request->isMethod('post') == "post"){ $pendaftar = new PendaftarModel(); $pendaftar->tgl

我正在使用Laravel创建项目,但在创建使用日期的表单时遇到了一些问题:

表或脚本中是否缺少某些内容? 这是桌子

这里是控制器

public function index(Request $request){
    $data = array();
    if($request->isMethod('post') == "post"){
        $pendaftar = new PendaftarModel();
        $pendaftar->tgl             =$request->input(['date']);
        $pendaftar->nopol           =$request->input('no polisi');
        $pendaftar->motor           =$request->input('jenis service');
        $pendaftar->servis          =$request->input('keluhan kendaraan');
        $pendaftar->keluhan         =$request->input('keluhan kendaraan');
        // $pendaftar->keluhan      =$request->input('keluhan kendaraan');

            if($pendaftar->save()){
                $data["status"]  = "success";
                $data["message"] = "Selamat, booking berhasil. Staff kami akan segera menghubungi anda untuk penjadwalan";
            }else {
                $data["status"]  = "danger";
                $data["message"] = "Maaf, Booking Gagal";
            }
    }
    return view("daftar", $data);
视图刀片

div class="well well-lg">
    <div class="container">
        <h2>Booking Online</h2>
        <span>Halaman untuk melakukan pendaftaran kendaraan.</span>
    </div>
</div>

<div class="container">

    <div class="alert alert-info">
        <i class="glyphicon glyphicon-info-sign"></i> Silahkan isi data berikut
    </div>
    <div class="panel panel-primary">

        <div class="panel-heading">
            Form Data Kendaraan
        </div>
        <div class="panel-body">

            @if(isset($status))
            <div class="alert alert-<?php echo $status; ?>">
                <?php echo $message; ?>
            </div>
            @endif

            <form method="post">
                {{ csrf_field() }}

            <div class="form-group">
                 <label for="tanggal">Pilih Tanggal</label>
                 <input class="form-control" id="tanggal" required type="date" name="tgl" max="3000-12-31" 
                        min="1000-01-01" placeholder="Pilih Tanggal">
            </div>

            <div class="form-group">
                <label for="nopol">Nomor Polisi:</label>
                <input class="form-control" id="nopol" required type="text" name="nopol" placeholder="Masukkan No Polisi">
            </div>

            <div class="form-group">
                <label for="motor">Jenis Motor:</label>
                <input class="form-control" id="motor" required type="text" name="motor" placeholder="Matic/Bebek/Sport">
            </div>

            <div class="form-group">
                <label for="servis">Tipe Service:</label>
                <input class="form-control" id="servis" required type="text" name="servis" placeholder="Besar/Kecils">
            </div>



            <div class="form-group">
                <label for="keluhan">Keluhan Kendaraan:</label>
                <textarea name="keluhan" id="keluhan" required class="form-control" rows="5" placeholder="Tulis Keluhan Motor Anda"></textarea>
            </div>

            <button type="submit" name="submit" class="btn btn-success btn-lg"><i class="glyphicon glyphicon-send"></i> Submit</button>
                <button type="reset" class="btn btn-danger btn-lg">Reset</button>
            </form>
        </div>
    </div>

</div>

在快照中,您的表缺少updated_at列,请在pendafter表中创建一个名为“updated_at”的列

另一种设置模型的方法如下:

{
//
protected $table = "pendaftar";
public $timestamps = false; //it should be false
protected $fillable=['tgl','nopol','motor','servis','keluhan'];
}

如果我将$timestamp更改为false。它将出现不同的错误“QueryException in Connection.php第647行:SQLSTATE[23000]:完整性约束冲突:1048列“tgl”不能为空(SQL:insert-into
pendaftar
tgl
nopol
motor
servis
keluhan
)值(,)“您尝试过其他解决方案吗?”?在ur表中添加更新的_at列。如果不添加,请将$timestamp设置为true,并将更新的_at列添加到表中。数据库中tgl的列类型是什么
{
//
protected $table = "pendaftar";
public $timestamps = false; //it should be false
protected $fillable=['tgl','nopol','motor','servis','keluhan'];
}