海南旅游SAAS
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.

42 lines
937 B

  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Http\Controllers\Controller;
  4. use App\Models\Notice;
  5. /**
  6. * 公告
  7. * Class NoticeController
  8. * @package App\Http\Controllers\Api
  9. */
  10. class NoticeController extends Controller
  11. {
  12. // 公告列表
  13. public function index()
  14. {
  15. $page = request()->input('page');
  16. if ($page && !ctype_digit($page)) {
  17. return $this->error('页码错误');
  18. }
  19. $list = Notice::where('agent_id', $this->agent_id)
  20. ->select(['title', 'updated_at'])
  21. ->orderBy('id', 'DESC')
  22. ->simplePaginate(15);
  23. return $this->success($list);
  24. }
  25. public function show()
  26. {
  27. $id = request()->input('id');
  28. if (!$id || !ctype_digit($id)) {
  29. return $this->error('无效的ID');
  30. }
  31. $data = Notice::where('agent_id', $this->agent_id)->find($id);
  32. if (!$data) {
  33. return $this->error('公告不存在或已删除');
  34. }
  35. return $this->success($data);
  36. }
  37. }