简体   繁体   中英

Error when input date on laravel 5.4

I am using Laravel to create a project but I get some issue when creating a form that uses date:

错误未知更新时间:

Is there something missing in the table or script? Here the table

表

Here the controller

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

The view blade

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>

The Model

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

In the snapshot, Your table is missing updated_at column, create a column with the name "updated_at" in your pendafter table.

Another way you can set the model like this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM