ServiceareaController.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. namespace App\Http\Controllers\Web\Content;
  3. use App\Http\Controllers\Web\WebBaseController;
  4. use App\Services\Content\ArticleService;
  5. use App\Services\Content\ArticleCategoryService;
  6. use App\Services\Content\AdService;
  7. use App\Services\Content\NavigationService;
  8. use Illuminate\Http\Request;
  9. use Illuminate\Support\Facades\Cache;
  10. use Illuminate\Support\Collection;
  11. class ServiceareaController extends WebBaseController
  12. {
  13. protected $articleService;
  14. protected $articleCategoryService;
  15. protected $adService;
  16. protected $navigationService;
  17. /**
  18. * ArticleController constructor.
  19. * @param $articleService
  20. * @param $articleCategoryService
  21. */
  22. public function __construct(ArticleService $articleService, ArticleCategoryService $articleCategoryService, AdService $adService, NavigationService $navigationService)
  23. {
  24. $this->articleService = $articleService;
  25. $this->articleCategoryService = $articleCategoryService;
  26. $this->adService = $adService;
  27. $this->navigationService = $navigationService;
  28. }
  29. public function list(Request $request, $id, $parent_id = '38', $num = '8', $focus = '3', $recommend = '4', $other_num = '5')
  30. {
  31. $key = $request->input('key');
  32. $lists = $this->articleService->list($key, $id, '10');
  33. $categorys = $this->articleCategoryService->getChildCategorys($parent_id, $num);
  34. //获取后台职场资讯名称
  35. $where = array(
  36. 'alias'=>'AIX_top',
  37. 'pagealias' => 'AIX_news',
  38. 'display'=>'1'
  39. );
  40. $topNav = $this->navigationService->getTopNav($where);
  41. $now_cate = '';
  42. $article_cate = array();
  43. foreach ($categorys as $k => $v) {
  44. if ($v->id == $id) {
  45. $now_cate = $v->category_name;
  46. $article_cate = $v;
  47. }
  48. }
  49. $this->putSeoData('article_cate', $article_cate);
  50. $return_data = array(
  51. 'articles'=>$lists,
  52. 'categorys'=>$categorys,
  53. 'key'=>$key,
  54. 'type_id'=>$id,
  55. 'top_nav'=>$topNav,
  56. 'now_cate'=>$now_cate
  57. );
  58. return view('app.content.servicearea.list', $return_data);
  59. }
  60. public function show($id, $parent_id = '38', $num = '8', $focus = '3', $recommend = '4', $other_num = '5')
  61. {
  62. $categorys = $this->articleCategoryService->getChildCategorys($parent_id, $num);
  63. $article_info = $this->articleService->getArticleInfo($id);
  64. if (!$article_info) {
  65. $back_url = \Illuminate\Support\Facades\URL::previous();
  66. return $this->showMessage('资讯不存在', $back_url, true, '上一页', '3');
  67. }
  68. $this->putSeoData('article', $article_info);
  69. $return_data = array(
  70. 'categorys'=>$categorys,
  71. 'type_id'=>$id,
  72. 'info'=>$article_info,
  73. 'parent_id'=>$parent_id
  74. );
  75. return view('app.content.servicearea.show', $return_data);
  76. }
  77. public function click($id)
  78. {
  79. $rst = $this->articleService->incrementData(array('id'=>$id), 1, 'click');
  80. $data = array('status'=>0);
  81. if ($rst) {
  82. $data = array('status'=>1);
  83. }
  84. return response()->json($data);
  85. }
  86. }