我正在使用laravel创建一个项目,但在创建使用日期的窗体时遇到了一些问题:
表或脚本中是否缺少某些内容?这是table
这里是控制器
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>
模型
{
//
protected $table = "pendaftar";
public $timestamps = true;
protected $fillable=['tgl','nopol','motor','servis','keluhan'];
}
1条答案
按热度按时间cvxl0en21#
在快照中,您的表缺少updated\u at列,请在pendafter表中创建一个名为“updated\u at”的列。
另一种设置模型的方法如下: