HelpController.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. namespace App\Http\Controllers\Web\Content;
  3. use App\Exceptions\ResponseException;
  4. use App\Http\Controllers\Web\WebBaseController;
  5. use App\Services\Content\HelpCategoryService;
  6. use App\Services\Content\HelpService;
  7. use App\Services\Content\AdService;
  8. use Illuminate\Http\Request;
  9. class HelpController extends WebBaseController
  10. {
  11. protected $helpCategoryService;
  12. protected $helpService;
  13. protected $adService;
  14. protected $ad_infos;
  15. /**
  16. * HelpController constructor.
  17. * @param $helpCategoryService
  18. */
  19. public function __construct(HelpCategoryService $helpCategoryService, HelpService $helpService, AdService $adService)
  20. {
  21. $this->helpCategoryService = $helpCategoryService;
  22. $this->helpService = $helpService;
  23. $this->adService = $adService;
  24. $this->ad_infos = $this->getAdInfo();
  25. }
  26. public function index()
  27. {
  28. //获取帮助中心分类信息
  29. $categories = $this->helpCategoryService->getCategories(array('parent_id'=>'0'), 15);
  30. $return_data = array(
  31. 'categories' => $categories,
  32. 'ads' => $this->ad_infos
  33. );
  34. return view('app.content.help.index', $return_data);
  35. }
  36. public function list($id)
  37. {
  38. $return_data = array();
  39. $helps = $this->helpService->getHelpsByType($id, '20');
  40. $categories = $this->helpCategoryService->noHelpCategories(array('parent_id'=>'0'), 15);
  41. $cate_info = $this->helpCategoryService->getOneCategory(array('id'=>$id));
  42. $this->putSeoData('help_cate', $cate_info);
  43. $return_data = array(
  44. 'categories' => $categories,
  45. 'helps' => $helps,
  46. 'cate_info' => $cate_info,
  47. 'ads' => $this->ad_infos
  48. );
  49. return view('app.content.help.list', $return_data);
  50. }
  51. public function search(Request $request, $filter = '')
  52. {
  53. $return_data = array();
  54. $key = $filter;
  55. if ($request->input('key')) {
  56. $key = $request->input('key');
  57. }
  58. $where[] = array('title','like','%'.$key.'%');
  59. $helps = $this->helpService->getHelps($where, '20');
  60. $categories = $this->helpCategoryService->noHelpCategories(array('parent_id'=>'0'), 15);
  61. $return_data = array(
  62. 'categories' => $categories,
  63. 'helps' => $helps,
  64. 'key' => $key,
  65. 'ads' => $this->ad_infos
  66. );
  67. return view('app.content.help.list', $return_data);
  68. }
  69. public function show($id)
  70. {
  71. $return_data = array();
  72. $categories = $this->helpCategoryService->noHelpCategories(array('parent_id'=>'0'), 15);
  73. $help_info = $this->helpService->getHelp(array('id'=>$id));
  74. $this->putSeoData('help', $help_info->toArray());
  75. $return_data = array(
  76. 'categories' => $categories,
  77. 'help_info' => $help_info,
  78. 'ads' => $this->ad_infos
  79. );
  80. return view('app.content.help.show', $return_data);
  81. }
  82. public function getAdInfo()
  83. {
  84. //$subsite_id = 0;
  85. $ad_data = array(
  86. 'theme' => 'default',
  87. 'org' => 'Home',
  88. 'alias' => 'AIX_help_top',
  89. 'num' => '1',
  90. //'subsite_id' => $subsite_id
  91. );
  92. $ad_infos = $this->adService->getAds($ad_data);
  93. return $ad_infos;
  94. }
  95. public function testEmail()
  96. {
  97. $this->orderService->testEmail();
  98. }
  99. }