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.

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