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

38 lines
901 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)->select(['title', 'updated_at'])->simplePaginate(15);
  20. return $this->success($list);
  21. }
  22. public function show()
  23. {
  24. $id = request()->input('id');
  25. if (!$id || !ctype_digit($id)) {
  26. return $this->error('无效的ID');
  27. }
  28. $data = Notice::where('agent_id', $this->agent_id)->find($id);
  29. if (!$data) {
  30. return $this->error('公告不存在或已删除');
  31. }
  32. return $this->success($data);
  33. }
  34. }