InformationController.php 908 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace App\Http\Controllers\Home;
  3. use App\Models\Article;
  4. use App\Http\Controllers\Home\BaseController;
  5. class InformationController extends BaseController
  6. {
  7. /* 视图文件相对路径 */
  8. protected $view = 'home.information';
  9. protected $view_art = 'home.article';
  10. public function __construct(Article $article)
  11. {
  12. $this->article = $article;
  13. parent::__construct();
  14. }
  15. // 新闻资讯页面
  16. public function showInformation()
  17. {
  18. return $this->showSecondMenuView('info', $this->view, $this->article);
  19. }
  20. // 文章详情页面
  21. public function showArticle($href1, $href2, $id)
  22. {
  23. $article = Article::find($id);
  24. if (!$article) {
  25. return redirect()->back()->with('error', '找不到该文章');
  26. }
  27. return $this->showThirdMenuView($this->view_art, $href1, $href2, $article);
  28. }
  29. }