1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- declare(strict_types=1);
- namespace app\model;
- use think\Model;
- /**
- * @mixin \think\Model
- */
- class CustomersSubscribe extends Model
- {
- protected $type = [
- 1 => '到店',
- 2 => '活动',
- 3 => '量房'
- ];
- public function getTypeAttr($value, $data)
- {
- if ($data['state'] == 0)
- return '预约' . $this->type[$value];
- if ($data['state'] < 0)
- return '已取消' . $this->type[$value];
- if ($data['state'] > 0)
- return '已' . $this->type[$value];
- }
- public function setTypeAttr($value)
- {
- $k = array_search($value, $this->type);
- if ($k === false) $k = 1;
- return $k;
- }
- public function customer()
- {
- return $this->belongsTo(Customer::class, 'customer_id');
- }
- public function org()
- {
- return $this->belongsTo(Org::class, 'org_id');
- }
- public function employee()
- {
- return $this->belongsTo(Employee::class, 'employee_id');
- }
- public function designer()
- {
- return $this->belongsTo(Employee::class, 'designer_id');
- }
- public function activity()
- {
- return $this->belongsTo(Activity::class, 'aid');
- }
- }
|