123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
- namespace app\model;
- use support\Model;
- class MedicalSalesman extends Model
- {
- protected $table = 'medical_salesman';
- protected $primaryKey = 'salesman_id';
- protected $dateFormat = 'U';
- public const CREATED_AT = 'salesman_addTime';
- public const UPDATED_AT = 'salesman_updateTime';
- public function shop()
- {
- return $this->hasOne(MedicalShop::class,'shop_id','salesman_shop_id');
- }
-
- public function phoneExist($phone)
- {
- return self::where('salesman_phone', $phone)->exists();
- }
-
- public function usernameExist($username)
- {
- return self::where('salesman_username', $username)->exists();
- }
-
- public function phoneIsInOtherAccountExist($phone, $id)
- {
- return self::where('salesman_phone', $phone)
- ->where('salesman_id', '<>', $id)
- ->exists();
- }
-
- public function usernameIsInOtherAccountExist($username, $id)
- {
- return self::where('salesman_username', $username)
- ->where('salesman_id', '<>', $id)
- ->exists();
- }
- }
|