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

35 lines
769 B

  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Http\Controllers\Controller;
  4. use App\Models\Article;
  5. use Illuminate\Http\Request;
  6. class ArticleController extends Controller
  7. {
  8. //文章列表
  9. public function index()
  10. {
  11. $list = Article::where('agent_id', $this->agent_id)
  12. ->select('id', 'image', 'title', 'updated_at')
  13. ->orderBy('id', 'DESC')
  14. ->simplePaginate(15);
  15. return $this->success($list);
  16. }
  17. //文章详情
  18. public function show()
  19. {
  20. $id = request()->input('id');
  21. if (!$id || !ctype_digit($id)) {
  22. return $this->error('未指定文章ID');
  23. }
  24. $article = Article::where('agent_id', $this->agent_id)->find($id);
  25. if (!$article) {
  26. return $this->error('文章不存在或已被删除');
  27. }
  28. return $this->success($article);
  29. }
  30. }