12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace app\common\model;
- use app\hander\HelpHander;
- use think\Db;
- use think\Exception;
- use think\Model;
- class PayWages extends Model
- {
- public function edit($userId){
- $data = [
- 'id' => input('id/d',0),
- 'content' => input('content','','trim'),
- 'update_time' => date('Y-m-d H:i:s')
- ];
- $result = validate('PayWages')->check($data,[],'');
- if(true !== $result){
- HelpHander::error(validate('PayWages')->getError());
- }
- $id = $data['id'];
- unset($data['id']);
- $ret = $this->allowField(true)->save($data,['id'=>$id]);
- if(!$ret){
- HelpHander::error('操作失败');
- }
- Db::name('pay_wages_log')->insert([
- 'pwid' => $id,
- 'user_id' => $userId,
- 'content' => $data['content'],
- 'create_time' => date('Y-m-d H:i:s')
- ]);
- return true;
- }
- public function info($companyId){
- $lists = Db::name('pay_wages')
- ->where('company_id',$companyId)
- ->select();
- $lists = $lists?$lists:[];
- foreach ($lists as $k=>$v){
- $lists[$k]['content'] = json_decode($v['content'],true);
- }
- return $lists;
- }
- public function all(){
- $lists = $this
- ->field('id,content,type,company_id')
- ->order('id desc')
- ->select();
- $lists = $lists?$lists->toArray():[];
- foreach ($lists as $k=>$v){
- $lists[$k]['content'] = json_decode($v['content'],true);
- }
- return $lists;
- }
- }
|