添加自己ORM基类中
public function create(array $param)
{
if ($this->model->getName('timestamps')) {
$time = time();
$date = date('Y-m-d H:i:s', $time);
$param['updated_at'] = $date;
$param['created_at'] = $date;
}
if (! empty($this->model->getName('guarded')) && ($this->model->getName('guarded')[0] == '*')) {
$fillable = $this->model->getName('fillable');
foreach ($param as $key => $val) {
if (! in_array($key, $fillable)) {
unset($param[$key]);
}
}
} else {
$fillable = $this->model->getName('guarded');
foreach ($param as $key => $val) {
if (in_array($key, $fillable)) {
unset($param[$key]);
}
}
}
return $this->model->insert($param);
}