| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- /**
- * 管理员仓库.
- *
- * @author jim <jim458734573@gmail.com>
- * @date 2020-01-23 00:27:19
- */
- declare(strict_types=1);
- namespace App\Repositories;
- use App\Model\ManagerModel;
- use KZ2\Repositories\Model\Repository;
- 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 $excludeManagerId 排除的用户ID.
- * @return bool
- */
- public function isExistsUsername($username, $excludeManagerId = '')
- {
- $model = new ManagerModel();
- if (!empty($excludeManagerId)) {
- $model = $model->where('manager_id', '!=', $excludeManagerId);
- }
- $model = $model->where('username', $username);
- return $model->exists();
- }
- }
|