1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <?php
- namespace app\common\model;
- use think\Model;
- use think\model\concern\SoftDelete;
- class Comjobs extends Model
- {
- use SoftDelete;
- protected $deleteTime = 'deletetime';
- protected $defaultSoftDelete = 0;
- // 设置字段信息
- protected $schema = [
- 'id' => 'int',
- 'workerid' => 'int',
- 'title' => 'string',
- 'video' => 'string',
- 'cateid' => 'int',
- 'province' => 'string',
- 'city' => 'string',
- 'district' => 'string',
- 'agegroup' => 'string',
- 'tags' => 'string',
- 'enddate' => 'int',
- 'requirement' => 'string',
- 'comdetails' => 'string',
- 'picall' => 'string',
- 'companydetails' => 'string',
- 'retmoney' => 'int',
- 'wtype' => 'tinyint',
- 'bwagall' => 'string',
- 'zwagall' => 'string',
- 'fwagall' => 'string',
- 'telephone' => 'string',
- 'remark' => 'string',
- 'status' => 'tinyint',
- 'priority' => 'int',
- 'updatetime' => 'int',
- 'createtime' => 'int',
- 'volume' => 'int',
- 'recruitment_cate' => 'int',
- 'latitude' => 'float',
- 'longitude' => 'float',
- 'address' => 'string',
- 'community' => 'string',
- ];
- // 设置字段自动转换类型
- protected $type = [
- 'tags' => 'json',
- 'picall' => 'json',
- 'enddate' => 'timestamp:Y-m-d',
- 'updatetime' => 'timestamp:Y-m-d H:i:s',
- 'createtime' => 'timestamp:Y-m-d H:i:s',
- ];
- // 设置JSON数据返回数组
- protected $jsonAssoc = true;
- public function getWtypeTextAttr($value, $data)
- {
- $wtype = [1 => '月薪', 2 => '日薪', 3 => '时薪', 4 => '面议'];
- return $wtype[$data['wtype']];
- }
- public function getRecruitmentCateTextAttr($value, $data)
- {
- $recruitment_cate = [1 => '普通招聘', 2 => '无忧聘'];
- return $recruitment_cate[$data['recruitment_cate']];
- }
- public function getStatusTextAttr($value, $data)
- {
- $status = [1 => '待修改', 2 => '待审核', 3 => '已上架', 4 => '已停招', 5 => '已下架'];
- return $status[$data['status']];
- }
- // 关联ComjobsCate
- public function comjobsCate()
- {
- return $this->hasOne(ComjobsCate::class, "id", "cateid");
- }
- // 关联Worker
- public function worker()
- {
- return $this->hasOne(Worker::class, "id", "workerid")->removeOption('soft_delete');
- }
- // 关联ComjobsLog
- public function comjobsLog()
- {
- return $this->hasMany(ComjobsLog::class, "comjobsid", "id");
- }
- }
|