我想使用以下Laravel函数将当前日期时间存储在MySQL中。实际上,我存储了一个静态日期。除此之外,我该如何将当前日期时间存储在数据库中的created_at
和updated_at
字段中?
function insert(Request $req)
{
$name = $req->input('name');
$address = $req->input('address');
$data = array("name" => $name, "address" => $address, "created_at" => '2017-04-27 10:29:59', "updated_at" => '2017-04-27 10:29:59');
DB::table('student')->insert($data);
echo "Record inserted successfully.<br/>";
return redirect('/');
}