GoodsCatesService.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Laravel框架 [ Laravel ]
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2017~2021 Laravel研发中心
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://www.laravel.cn
  8. // +----------------------------------------------------------------------
  9. // | Author: wesmiler <12345678@qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace App\Services;
  12. use App\Models\ArticleCatesModel;
  13. use App\Models\GoodsCatesModel;
  14. /**
  15. * 商品分类管理-服务类
  16. * @author wesmiler
  17. * @since 2020/11/11
  18. * Class GoodsCatesService
  19. * @package App\Services
  20. */
  21. class GoodsCatesService extends BaseService
  22. {
  23. /**
  24. * 构造函数
  25. * @author wesmiler
  26. * @since 2020/11/11
  27. * GoodsCatesService constructor.
  28. */
  29. public function __construct()
  30. {
  31. $this->model = new GoodsCatesModel();
  32. }
  33. /**
  34. * 获取列表
  35. * @return array
  36. * @since 2020/11/11
  37. * @author wesmiler
  38. */
  39. public function getList()
  40. {
  41. $params = request()->all();
  42. return parent::getList();
  43. }
  44. /**
  45. * 获取分类选项列表
  46. * @param int $num
  47. * @return array
  48. */
  49. public function getOptions(){
  50. $params = request()->all();
  51. $num = isset($params['num'])? $params['num'] : 0;
  52. $datas = $this->model->where(['status'=> 1])->select(['id','pid','name','status'])->orderBy('sort','desc')->limit($num? $num : 999999)->get();
  53. return message(MESSAGE_OK, true, $datas);
  54. }
  55. /**
  56. * 添加或编辑
  57. * @return array
  58. * @since 2020/11/11
  59. * @author wesmiler
  60. */
  61. public function edit()
  62. {
  63. $data = request()->all();
  64. $data['update_time'] = time();
  65. return parent::edit($data); // TODO: Change the autogenerated stub
  66. }
  67. }