ExplainController.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace App\Http\Controllers\Web\Content;
  3. use App\Http\Controllers\Web\WebBaseController;
  4. use App\Services\Content\ExplainService;
  5. use Illuminate\Http\Request;
  6. use Illuminate\Support\Facades\Cache;
  7. use App\Services\Content\AdService;
  8. class ExplainController extends WebBaseController
  9. {
  10. protected $explainService;
  11. protected $adService;
  12. /**
  13. * ExplainController constructor.
  14. * @param $explainService
  15. */
  16. public function __construct(ExplainService $explainService, AdService $adService)
  17. {
  18. $this->explainService = $explainService;
  19. $this->adService = $adService;
  20. }
  21. public function show($id)
  22. {
  23. $where = array('id'=>$id,'is_display'=>'1');
  24. $info = $this->explainService->getExplainInfo($where);
  25. if (!$info) {
  26. $back_url = \Illuminate\Support\Facades\URL::previous();
  27. return $this->showMessage('说明不存在', $back_url, true, '上一页', '3');
  28. }
  29. $this->putSeoData('explain', $info);
  30. //获取所有说明页并按所属分类分组显示
  31. $lists = $this->explainService->getMenuExplains(array('is_display'=>'1'));
  32. $ad_data = array(
  33. 'theme' => 'default',
  34. 'org' => 'Home',
  35. 'alias' => 'AIX_explain_show_top',
  36. 'num' => '1'
  37. );
  38. $ad_infos = $this->adService->getAds($ad_data);
  39. $return_data = array(
  40. 'info' => $info,
  41. 'lists'=>$lists,
  42. 'ads' => $ad_infos
  43. );
  44. return view('app.content.explain.show', $return_data);
  45. }
  46. public function click($id)
  47. {
  48. $rst = $this->explainService->incrementData(array('id'=>$id), 1, 'click');
  49. $data = array('status'=>0);
  50. if ($rst) {
  51. $data = array('status'=>1);
  52. }
  53. return response()->json($data);
  54. }
  55. }