| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <?php
- /**
- * 描述.
- *
- * @author nj
- * @date 2021-05-18 20:45:46
- */
- namespace App\Repositories;
- use KZ2\Laravel\Repositories\Eloquent\Repository;
- use App\Models\Mysql\ManagerModel;
- class ManagerRepository extends Repository
- {
- public function model()
- {
- return ManagerModel::class;
- }
- /**
- * 生成密码.
- * @param string $plain 明文密码.
- * @param string $salt 盐.
- * @return string
- */
- public function generatePassword($plain, $salt)
- {
- return md5(md5($plain) . $salt);
- }
- /**
- * 是否存在相同用户名.
- * @param string $username 用户名.
- * @param string $excludeManagerUid 排除的用户ID.
- * @return bool
- */
- public function isExistsUsername($username, $excludeManagerUid = '')
- {
- $model = new ManagerModel();
- if (!empty($excludeManagerUid)) {
- $model = $model->where('manager_uid', '!=', $excludeManagerUid);
- }
- $model = $model->where('username', $username);
- return $model->exists();
- }
- }
|