CpUser.php 723 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace App\Modules\CpUser\Models;
  3. use Illuminate\Database\Eloquent\Model;
  4. class CpUser extends Model
  5. {
  6. protected $table = 'cp_users';
  7. protected $fillable = ['username','password','id_enabled','created_at','updated_at'];
  8. /**
  9. * 获取用户
  10. */
  11. public static function getCpUser($username) {
  12. return self::where(['username'=>$username])->first();
  13. }
  14. /**
  15. * 获取用户by id
  16. */
  17. public static function getCpUserById($id) {
  18. return self::where(['id'=>$id])->first();
  19. }
  20. //修改密码
  21. static function modifyPassword($username, $password)
  22. {
  23. return self::where('username', $username)->update(compact('password'));
  24. }
  25. }