一、增加
1.静态
2.控制器
public function add(){
if(request()->isAjax()){
$param = input('post.');
unset($param['file']);
$article = new RecruitmentModel();
$flag = $article->insertRecruitment($param);
return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
}
return $this->fetch();
}
3.模板
protected $name = 'recruitment';
public function getRecruitment()
{
return $this->order('id asc')->select();
}
//增加
public function insertRecruitment($param)
{
try{
$result = $this->save($param);
if(false === $result){
return ['code' => -1, 'data' => '', 'msg' => $this->getError()];
}else{
return ['code' => 1, 'data' => '', 'msg' => '诚聘英才添加成功'];
}
}catch( PDOException $e){
return ['code' => -2, 'data' => '', 'msg' => $e->getMessage()];
}
}
二、编辑
1.静态
2.控制器
public function edit($id){
$result = Db::table('think_recruitment')->where('id', $id)->find();
$this->assign('result', $result);
$article = new RecruitmentModel();
if(request()->isAjax()){
$param = input('post.');
unset($param['file']);
$flag = $article->editRecruitment($param);
return json(['code' => $flag['code'], 'data' => $flag['data'], 'msg' => $flag['msg']]);
}
return $this->fetch();
}3.模板
protected $name = 'recruitment';
public function getRecruitment()
{
return $this->order('id asc')->select();
}
//编辑
public function editRecruitment($param)
{
try{
$result = $this->save($param, ['id' => $param['id']]);
if(false === $result){
return ['code' => 0, 'data' => '', 'msg' => $this->getError()];
}else{
return ['code' => 1, 'data' => '', 'msg' => '诚聘英才编辑成功'];
}
}catch( PDOException $e){
return ['code' => 0, 'data' => '', 'msg' => $e->getMessage()];
}
}三。。。。。。。。。。。。。完成 多个富文本 增加修改成功 棒棒哒
转载于:https://www.cnblogs.com/dennyxiao/p/8441411.html