RoleData.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace app\v1\model\customer;
  3. use plugin\saiadmin\basic\BaseNormalModel;
  4. /**
  5. * 角色查询模型
  6. */
  7. class RoleData extends BaseNormalModel
  8. {
  9. /**
  10. * 数据表主键
  11. * @var string
  12. */
  13. protected $pk = 'id';
  14. /**
  15. * 数据库表名称
  16. * @var string
  17. */
  18. protected $table = 'role_data_and';
  19. /**
  20. * 数据库连接
  21. * @var string
  22. */
  23. protected $connection = 'db_game_log';
  24. /**
  25. * 用户名 搜索
  26. */
  27. public function searchUserNameAttr($query, $value)
  28. {
  29. $query->where('user_name', 'like', '%'.$value.'%');
  30. }
  31. /**
  32. * 角色名 搜索
  33. */
  34. public function searchRoleNameAttr($query, $value)
  35. {
  36. $query->where('role_name', 'like', '%'.$value.'%');
  37. }
  38. /**
  39. * 游戏ID搜索器
  40. */
  41. public function searchGameIdAttr($query, $value)
  42. {
  43. if (is_array($value)) {
  44. $query->whereIn('game_id', $value);
  45. } else {
  46. $query->where('game_id', $value);
  47. }
  48. }
  49. }