如 :
public function saveNotice($noticeRequest){ $notice = new Notice; $data = $noticeRequest->only($notice->getFillable()); $notice->school_id = \Auth::user()->school_id; $notice->fill($data)->save(); }
但是呢,我出现了bug,当 验证的时候,允许字段为空,然后就出现了 sql的bug
决解方法在建立的表这些字段必须允许为空,laravel有迁移文件,所以把迁移文件设置,字段中加 nullable()
$table->timestamp('start_date')->nullable();