1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- namespace app\model;
- use support\Model;
- class SysUser extends Model
- {
- protected $table = 'sys_user';
- protected $primaryKey = 'user_id';
- public const UPDATED_AT = null;
- protected $keyType = 'string';
- public function getUserAddtimesAttribute($value)
- {
- return date('Y-m-d H:i:s', $value);
- }
- public function role()
- {
- return $this->hasOne(SysRole::class, 'role_id', 'join_user_role_id')
- ->select('role_id', 'role_name');
- }
- public function dept()
- {
- return $this->hasOne(SysDept::class, 'dept_id', 'join_user_dept_id')
- ->select('dept_id', 'dept_name');
- }
- /* 按登录名查找用户 */
- public static function findByLoginName($name)
- {
- return self::where('user_login_name', $name)->first();
- }
- /**
- * @Desc 修改用户状态
- * @Author Gorden
- * @Date 2024/3/12 13:20
- *
- * @param $id
- * @param $data
- * @return int
- */
- public static function updateStatus($id, $data)
- {
- return self::where('user_id', $id)->update($data);
- }
- }
|