1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- <?php namespace App\Models\WeiBan;
- use Illuminate\Database\Eloquent\Factories\HasFactory;
- use Illuminate\Database\Eloquent\Model;
- use App\Models\Traits\MultipUpdate;
- /**
- * 微伴用户模型
- *
- */
- class Follow extends Model
- {
- use HasFactory,MultipUpdate;
- // 与模型关联的表名
- protected $table = 'weiban_follow';
- // 是否主动维护时间戳
- public $timestamps = false;
- // 定义时间戳字段名
- // const CREATED_AT = 'insert_time';
- // const UPDATED_AT = 'update_time';
- /**
- * 添加数据
- *
- */
- public function add($data)
- {
- // 时间
- $data['insert_time'] = time();
- $data['update_time'] = time();
- // 写入数据表
- $id = $this->query()->insertGetId($data);
- // 如果操作失败
- if( !$id ) return $id;
- // 返回结果
- return $id;
- }
- /**
- * 添加数据
- *
- */
- public function edit($id,$data)
- {
- // 更新时间
- $data['update_time'] = time();
- // 写入数据表
- $result = $this->query()->where(['id'=>$id])->update($data);
- // 失败返回0
- if( !$result ) return '';
- // 返回结果
- return $id;
- }
- /**
- * 添加数据
- *
- */
- public function getListByWeibanExtid($weibanExtid)
- {
- // 返回结果
- $list = $this->query()->where([['weiban_extid','=',$weibanExtid]])->get(['id','staff_id','staff_name','staff_avatar','phone_number','status','remark','remark_state','weiban_extid','remark_corp_name'])->toArray();
- // 返回结果
- if( !$list ) return [];
- // 数据结构
- return $list;
- }
- }
|