IndexController.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. namespace App\Http\Home\Pdf;
  3. use App\Http\Home\HttpBaseController;
  4. use Illuminate\Support\Facades\DB;
  5. use Illuminate\Support\Facades\Request;
  6. use Illuminate\Support\Facades\View;
  7. class IndexController extends HttpBaseController
  8. {
  9. private $productInfo;
  10. private $windowsVersionInfo;
  11. public function __construct()
  12. {
  13. parent::__construct();
  14. // 获取产品信息
  15. $this->productInfo = $this->getProductInfo('LfkbKXGSo9wC');
  16. View::share('productInfo', $this->productInfo);
  17. // 获取当前的Windows下载版本 product_version
  18. $this->windowsVersionInfo = $this->getProductVersion($this->productInfo->id);
  19. View::share('windowsVersionInfo', $this->windowsVersionInfo);
  20. }
  21. /**
  22. * 首页
  23. */
  24. public function index()
  25. {
  26. return view('pdf/index');
  27. }
  28. public function help($cid = '')
  29. {
  30. $size = 15;
  31. $page = Request::input('page', 1);
  32. // 获取资讯分类列表
  33. $category = DB::table('news_category')->where('product_id', $this->productInfo->id)->orderBy('id', 'asc')->get();
  34. if (empty($cid) && $category) {
  35. $cid = $category[0]->mid;
  36. }
  37. // 获取资讯列表
  38. $find = DB::table('news')->where('product_id', $this->productInfo->id)
  39. ->offset($size * ($page - 1))
  40. ->orderBy('id', 'desc')
  41. ->limit($size);
  42. if ($cid) {
  43. $info = DB::table('news_category')->select('id')->where('mid', $cid)->first();
  44. if ($info) {
  45. $find->where('category_id', $info->id);
  46. }
  47. }
  48. $list = $find->get();
  49. return view('compress/help', ['cid' => $cid, 'category' => $category, 'list' => $list]);
  50. }
  51. /**
  52. * 资讯详情
  53. */
  54. public function newsDetail($mid)
  55. {
  56. // 获取资讯列表
  57. $info = DB::table('news')->where('mid', $mid)->where('is_delete', 0)->first();
  58. // 热门点击
  59. $hotList = DB::table('news')->where('product_id', $this->productInfo->id)->where('category_id', $info->category_id)
  60. ->offset(mt_rand(7, 10))
  61. ->orderBy('id', 'desc')
  62. ->limit(6)
  63. ->get();
  64. // 最近更新
  65. $recentList = DB::table('news')->where('product_id', $this->productInfo->id)->where('category_id', $info->category_id)
  66. ->orderBy('id', 'desc')
  67. ->limit(6)
  68. ->get();
  69. return view('compress/news_detail', ['info' => $info, 'hotList' => $hotList, 'recentList' => $recentList]);
  70. }
  71. public function about()
  72. {
  73. return view('compress/about');
  74. }
  75. }