dimanche 29 avril 2018

Error when input date on laravel 5.4

i have using laravel to create prject. But i get some issue when creating a form that using date. Error unknown updated_at

Is there something missing in the table or script? Here the table 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">
                

            <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'];

}

Please help me to fix this, any comment will appreciate.

Bestly Regards



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire