You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
1.7 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. <?php
  2. namespace App\Http\Model;
  3. class UserPoint extends BaseModel
  4. {
  5. //用户积分明细
  6. protected $table = 'user_point';
  7. public $timestamps = false;
  8. /**
  9. * 不能被批量赋值的属性
  10. *
  11. * @var array
  12. */
  13. protected $guarded = array();
  14. //获取列表
  15. public static function getList(array $param)
  16. {
  17. extract($param); //参数:limit,offset
  18. $where['user_id'] = $user_id;
  19. $limit = isset($limit) ? $limit : 10;
  20. $offset = isset($offset) ? $offset : 0;
  21. $model = new UserPoint;
  22. if(isset($type)){$where['type'] = $type;}
  23. $model = $model->where($where);
  24. $res['count'] = $model->count();
  25. $res['list'] = array();
  26. if($res['count']>0)
  27. {
  28. $res['list'] = $model->skip($offset)->take($limit)->orderBy('id','desc')->get();
  29. }
  30. else
  31. {
  32. return false;
  33. }
  34. return $res;
  35. }
  36. public static function getOne($id)
  37. {
  38. return self::where('id', $id)->first();
  39. }
  40. public static function add(array $data)
  41. {
  42. if ($id = self::insertGetId($data))
  43. {
  44. return $id;
  45. }
  46. return false;
  47. }
  48. public static function modify($where, array $data)
  49. {
  50. if (self::where($where)->update($data))
  51. {
  52. return true;
  53. }
  54. return false;
  55. }
  56. //删除一条记录
  57. public static function remove($id)
  58. {
  59. if (!self::whereIn('id', explode(',', $id))->delete())
  60. {
  61. return false;
  62. }
  63. return true;
  64. }
  65. }