1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace app\common\model;
- use app\hander\HelpHander;
- use think\Db;
- use think\Model;
- class AssetExportTemp extends Model
- {
- public function add(){
- $data = [
- 'id' => input('id/d',0),
- 'title' => input('title','','trim'),
- 'content' => input('content','','trim'),
- ];
- $result = validate('AssetExportTemp')->check($data,[],'');
- if(true !== $result){
- HelpHander::error(validate('AssetExportTemp')->getError());
- }
- $id = $data['id'];
- unset($data['id']);
- if($id > 0){
- $data['update_time'] = date('Y-m-d H:i:s');
- $ret = $this->allowField(true)->save($data,['id'=>$id]);
- }else{
- $data['create_time'] = date('Y-m-d H:i:s');
- $ret = $this->allowField(true)->save($data);
- }
- if(!$ret){
- HelpHander::error('操作失败');
- }
- return true;
- }
- public function all($orgId){
- $lists = $this
- ->field('id,title,content')
- ->order('id desc')
- ->select();
- return $lists?$lists->toArray():[];
- }
- public function del($id){
- $ret = $this->where('id',$id)->delete();
- if(!$ret){
- HelpHander::error('删除失败');
- }
- return true;
- }
- }
|