12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- namespace app\admin\model;
- use think\Model;
- class Protector extends Model
- {
- // 表名
- protected $table = 'protector';
-
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = false;
- // 定义时间戳字段名
- protected $createTime = false;
- protected $updateTime = false;
-
- // 追加属性
- protected $append = [
- ];
- /**
- * 判断单位是否存在,存在返回name
- * @param $unit_name
- * @return bool|mixed
- */
- public static function unitNameIsExist($unit_name)
- {
- $res = self::where('unit_name',$unit_name)
- ->value('unit_name');
- return $res;
- }
- /**
- * 判断用户是否超出保护个数上限
- * @param $usr_id
- * @param $count
- * @return bool|string
- */
- public static function proCountIsExceed($usr_id, $count)
- {
- $exist_count = self::where('usr_id',$usr_id)
- ->where('status',0)
- ->count();
- if($exist_count >= $count){
- return '保护客户个数已超出上限!';
- }
- return false;
- }
-
- }
|