Article.php 927 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. namespace app\api\controller\plus\article;
  3. use app\api\controller\Controller;
  4. use app\api\model\plus\article\Article as ArticleModel;
  5. use app\api\model\plus\article\Category as CategoryModel;
  6. /**
  7. * 文章控制器
  8. */
  9. class Article extends Controller
  10. {
  11. /**
  12. *获取分类
  13. */
  14. public function category()
  15. {
  16. // 文章分类
  17. $category = CategoryModel::getAll();
  18. return $this->renderSuccess('', compact('category'));
  19. }
  20. /**
  21. * 文章列表
  22. */
  23. public function index($category_id = 0)
  24. {
  25. $model = new ArticleModel;
  26. $list = $model->getList($category_id, $this->postData());
  27. return $this->renderSuccess('', compact('list'));
  28. }
  29. /**
  30. *文章详情
  31. */
  32. public function detail($article_id)
  33. {
  34. $detail = ArticleModel::detail($article_id);
  35. return $this->renderSuccess('', compact('detail'));
  36. }
  37. }