2020-04-29 17:37:45 +08:00
|
|
|
<?php
|
|
|
|
namespace catchAdmin\permissions\model\search;
|
|
|
|
|
2020-09-08 14:36:32 +08:00
|
|
|
use catchAdmin\permissions\model\Department;
|
|
|
|
|
2020-04-29 17:37:45 +08:00
|
|
|
trait UserSearch
|
|
|
|
{
|
|
|
|
public function searchUsernameAttr($query, $value, $data)
|
|
|
|
{
|
|
|
|
return $query->whereLike('username', $value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function searchEmailAttr($query, $value, $data)
|
|
|
|
{
|
|
|
|
return $query->whereLike('email', $value);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function searchStatusAttr($query, $value, $data)
|
|
|
|
{
|
|
|
|
return $query->where($this->aliasField('status'), $value);
|
|
|
|
}
|
|
|
|
|
2020-11-04 10:06:23 +08:00
|
|
|
/**
|
|
|
|
* 查询部门下的用户
|
|
|
|
*
|
|
|
|
* @time 2020年11月04日
|
|
|
|
* @param $query
|
|
|
|
* @param $value
|
|
|
|
* @param $data
|
|
|
|
* @throws \think\db\exception\DataNotFoundException
|
|
|
|
* @throws \think\db\exception\DbException
|
|
|
|
* @throws \think\db\exception\ModelNotFoundException
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2020-04-29 17:37:45 +08:00
|
|
|
public function searchDepartmentIdAttr($query, $value, $data)
|
|
|
|
{
|
2020-11-04 10:06:23 +08:00
|
|
|
return $query->whereIn($this->aliasField('department_id'), Department::getChildrenDepartmentIds($value));
|
2020-04-29 17:37:45 +08:00
|
|
|
}
|
|
|
|
}
|