NoticeService.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2017~2021 LARAVEL研发中心
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://www.laravel.cn
  8. // +----------------------------------------------------------------------
  9. // | Author: laravel开发员 <laravel.qq.com>
  10. // +----------------------------------------------------------------------
  11. namespace App\Services\Common;
  12. use App\Models\NoticeModel;
  13. use App\Services\BaseService;
  14. /**
  15. * 通知公告-服务类
  16. * @author laravel开发员
  17. * @since 2020/11/11
  18. * Class NoticeService
  19. * @package App\Services\Common
  20. */
  21. class NoticeService extends BaseService
  22. {
  23. /**
  24. * 构造函数
  25. * @author laravel开发员
  26. * @since 2020/11/11
  27. * NoticeService constructor.
  28. */
  29. public function __construct()
  30. {
  31. $this->model = new NoticeModel();
  32. }
  33. /**
  34. * 设置置顶
  35. * @return array
  36. * @since 2020/11/21
  37. * @author laravel开发员
  38. */
  39. public function setIsTop()
  40. {
  41. $data = request()->all();
  42. if (!$data['id']) {
  43. return message('记录ID不能为空', false);
  44. }
  45. if (!$data['is_top']) {
  46. return message('设置置顶不能为空', false);
  47. }
  48. $error = '';
  49. $item = [
  50. 'id' => $data['id'],
  51. 'is_top' => $data['is_top']
  52. ];
  53. $rowId = $this->model->edit($item, $error);
  54. if (!$rowId) {
  55. return message($error, false);
  56. }
  57. return message();
  58. }
  59. }