ArticleController.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace App\Http\Controllers\Web\Hardware\Aio;
  3. use App\Http\Controllers\Web\WebBaseController;
  4. use Illuminate\Http\Request;
  5. use App\Services\Content\ArticleService;
  6. class ArticleController extends WebBaseController
  7. {
  8. protected $articleService;
  9. /**
  10. * ArticleController constructor.
  11. */
  12. public function __construct(ArticleService $articleService)
  13. {
  14. $this->articleService = $articleService;
  15. }
  16. public function index(Request $request, $id = '31', $num = 4)
  17. {
  18. $key = $request->input('key', '');
  19. $rst = $this->articleService->list($key, $id, $num);
  20. $return_data = array(
  21. 'articles' => $rst,
  22. 'key' => $key
  23. );
  24. return view('app.hardware.aio.article.index', $return_data);
  25. }
  26. public function show(Request $request, $id)
  27. {
  28. $article_info = $this->articleService->getArticleInfo($id);
  29. if (!$article_info) {
  30. $back_url = \Illuminate\Support\Facades\URL::previous();
  31. return $this->showMessage('政策公告不存在', $back_url, true, '上一页', '3');
  32. }
  33. $this->putSeoData('article', $article_info);
  34. $return_data = array(
  35. 'type_id'=>$id,
  36. 'info'=>$article_info
  37. );
  38. return view('app.hardware.aio.article.show', $return_data);
  39. }
  40. }