/**
* 保存新建的资源
*
* @param \think\Request $request
* @return \think\Response
*/
public function save(Request $request){
$params = $request->post();
if(!$params["user"])return Json::fail('请输入发送人!');
if(!$params["title"])return Json::fail('请输入通知标题!');
if(!$params["content"])return Json::fail('请输入通知内容!');
if($params["type"] == 2){
$uids = UserModel::order('uid desc')->column("uid");
$params["uid"] = count($uids) > 0 ? ",".implode(",",$uids)."," : "";
}
$params["add_time"] = time();
UserNoticeModel::set($params);
return Json::successful('添加成功!');
}
添加站内通知时 传入参数为1 -> $params[size=12.8pt][[/size][size=12.8pt]"type"[/size][size=12.8pt]] ==1 . [/size]$params[size=12.8pt][[/size][size=12.8pt]"uid"[/size][size=12.8pt]] 好像没有给默认值,导致插入数据[/size]SQLSTATE[HY000]: General error: 1364 Field 'uid' doesn't have a default value