DownloadController.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace App\Http\Home\Watermark;
  3. use App\Http\Home\HttpBaseController;
  4. use Illuminate\Support\Facades\DB;
  5. use Illuminate\Support\Facades\Request;
  6. class DownloadController extends HttpBaseController
  7. {
  8. private array $softInfo = [
  9. 'id' => 3,
  10. 'title' => "助友水印工厂",
  11. ];
  12. public function __construct()
  13. {
  14. parent::__construct();
  15. }
  16. /**
  17. * 首页
  18. */
  19. public function index()
  20. {
  21. $deviceType = Request::input('type'); // '操作系统类型 windows linux android ios
  22. if (!in_array($deviceType, ['windows', 'linux', 'android', 'ios'])) {
  23. $deviceType = 'windows';
  24. }
  25. // 获取下载地址,然后跳转
  26. $info = DB::table('product_version')
  27. ->where('os_type', $deviceType)
  28. ->where('id', $this->softInfo['id'])
  29. ->where('status', 1)
  30. ->orderBy('id', 'desc')
  31. ->first();
  32. if (empty($info)) {
  33. $url = '/';
  34. } else {
  35. $url = $info->download_url;
  36. }
  37. return responseMessage(1001, '', $url);
  38. }
  39. }