Admin.php 960 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. class Admin extends Model
  5. {
  6. // 设置字段信息
  7. protected $schema = [
  8. 'id' => 'int',
  9. 'role' => 'tinyint',
  10. 'adminname' => 'string',
  11. 'password' => 'string',
  12. 'status' => 'tinyint',
  13. 'realname' => 'string',
  14. 'mobile' => 'string',
  15. 'joindate' => 'int',
  16. 'joinip' => 'string',
  17. 'lastdate' => 'int',
  18. 'lastip' => 'string',
  19. 'powerids' => 'string',
  20. 'remark' => 'string'
  21. ];
  22. // 设置字段自动转换类型
  23. protected $type = [
  24. 'joindate' => 'timestamp:Y-m-d H:i:s',
  25. 'lastdate' => 'timestamp:Y-m-d H:i:s',
  26. ];
  27. public function getStatusTextAttr($value,$data)
  28. {
  29. $status = [1=>'正常',2=>'禁用'];
  30. return $status[$data['status']];
  31. }
  32. public function getRoleTextAttr($value,$data)
  33. {
  34. $role = [1=>'超级管理员',2=>'普通管理员'];
  35. return $role[$data['role']];
  36. }
  37. }