为什么新增数据的created_at没有自动维护

来源:2-4 Laravel-通过表单实现新增及操作状态提示功能

qq_春秋入我心_gjpv16

2018-10-20 18:55

class Student extends Model

{

protected $table = 'student';


public $timestamps = true;


protected function getDateFromat()

{

return time();

}


protected function asDateTime($val)

{

return $val;

}

}


public function save(Request $request)

{

$data = $request->input('Student');

//var_dump($data);

$students = new Student();

$students->name = $data['name'];

$students->age = $data['age'];

$students->sex = $data['sex'];

//$student->save();

if($students->save()){

return redirect('student/index');

}else{

return redirect()->back();

}

}


写回答 关注

2回答

  • 渗透_
    2019-11-19 11:03:56
    getDateFromat改getDateFormat
  • L_yeluo
    2018-10-25 12:04:44

    protected function getDateFromat() 改成 public  function getDateFromat() 试试?

轻松学会Laravel-表单篇

Laravel框架是世界上最流行的PHP框架,没有之一

32653 学习 · 255 问题

查看课程

相似问题