ArticleCatesService.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. /**
  14. * 文章分类管理-服务类
  15. * @author wesmiler
  16. * @since 2020/11/11
  17. * Class ArticleCatesService
  18. * @package App\Services
  19. */
  20. class ArticleCatesService extends BaseService
  21. {
  22. /**
  23. * 构造函数
  24. * @author wesmiler
  25. * @since 2020/11/11
  26. * ArticleCatesService constructor.
  27. */
  28. public function __construct()
  29. {
  30. $this->model = new ArticleCatesModel();
  31. }
  32. /**
  33. * 获取列表
  34. * @return array
  35. * @since 2020/11/11
  36. * @author wesmiler
  37. */
  38. public function getList()
  39. {
  40. $params = request()->all();
  41. return parent::getList();
  42. }
  43. /**
  44. * 获取分类选项列表
  45. * @param int $num
  46. * @return array
  47. */
  48. public function getOptions(){
  49. $params = request()->all();
  50. $num = isset($params['num'])? $params['num'] : 0;
  51. $type = isset($params['type'])? $params['type'] : 0;
  52. $where = ['status'=>1];
  53. if($type>0){
  54. $where['type'] = $type;
  55. }
  56. $datas = $this->model->where($where)
  57. ->select(['id','pid','name','status'])
  58. ->orderBy('sort','asc')
  59. ->limit($num? $num : 999999)
  60. ->get();
  61. return message(MESSAGE_OK, true, $datas);
  62. }
  63. /**
  64. * 添加或编辑
  65. * @return array
  66. * @since 2020/11/11
  67. * @author wesmiler
  68. */
  69. public function edit()
  70. {
  71. $data = request()->all();
  72. $data['update_time'] = time();
  73. return parent::edit($data); // TODO: Change the autogenerated stub
  74. }
  75. }