1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- namespace app\model;
- use app\event\Msg;
- use think\Model;
- use think\facade\Console;
- class CustomerClue extends Model
- {
- public function org()
- {
- return $this->belongsTo(Org::class, 'org_id')->bind(['org_name' => 'info']);
- }
- public function employee()
- {
- return $this->belongsTo(Employee::class, 'employee_id')->bind(['employee_name' => 'name']);
- }
- public function user()
- {
- return $this->belongsTo(User::class, 'uid')->bind(['nickname' => 'nickname','sex','wxphone' => 'phone','headimgurl']);
- }
- public function getState($value)
- {
- $state = ['', '建档', '无效'];
- return $state[$value];
- }
- public static function onAfterInsert($clue)
- {
- if($clue->employee_id){
- event(new Msg($clue->employee_id, '您有一条新线索,请注意查看', 'clue'));
- //累计勋章
- Console::call('medal',['clue',(string)$clue->employee_id,'']);
- }
- }
- public function subscribe()
- {
- return $this->belongsTo(CustomerSubscribe::class, 'uid','uid');
- }
- public function footprints()
- {
- return $this->belongsTo(Footprints::class, 'uid','uid');
- }
- }
|