web.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?php
  2. use Illuminate\Support\Facades\Route;
  3. use App\Http\Controllers\HomeController;
  4. use App\Http\Controllers\ProductController;
  5. use App\Http\Controllers\PageController;
  6. use App\Http\Controllers\ContactController;
  7. use App\Http\Controllers\VideoController;
  8. use App\Http\Controllers\DemoController;
  9. use App\Http\Controllers\SitemapController;
  10. use App\Http\Controllers\CollectionController;
  11. use App\Models\DistProductCategory;
  12. use App\Models\SitePage;
  13. /*
  14. |--------------------------------------------------------------------------
  15. | Web Routes
  16. |--------------------------------------------------------------------------
  17. |
  18. | Here is where you can register web routes for your application. These
  19. | routes are loaded by the RouteServiceProvider and all of them will
  20. | be assigned to the "web" middleware group. Make something great!
  21. |
  22. */
  23. //巴西官网专用路由
  24. //$host = $_SERVER['HTTP_HOST']; // 获取当前域名
  25. //
  26. //if ($host == 'internal-demo-site.mietubl.com.cn') {
  27. // Route::get('/{slug}', function ($slug) {
  28. // // 查询数据库,将 category_slug 转换为对应ID
  29. // $categoryId = DistProductCategory::where(function ($query) use ($slug) {
  30. // $query->where('slug', $slug);
  31. // })
  32. // ->where('dist_id', getDistId())
  33. // ->first();
  34. //
  35. // if ($categoryId) {
  36. // $productController = new ProductController();
  37. // return $productController->category($slug);
  38. // } else {
  39. // $page = SitePage::where('status', '1')->where('dist_id', getDistId())->where('slug', $slug)->first();
  40. // if ($page) {
  41. //// $pageController = new PageController();
  42. //// return $pageController->detail($page);
  43. // return Route::get('/{slug}', [PageController::class, 'detail'])->name('page.detail');
  44. // }
  45. // }
  46. // });
  47. // Route::get('/produto/{slug}', function ($slug) {
  48. // $productController = new ProductController();
  49. // return $productController->detail($slug);
  50. // });
  51. //}
  52. Route::get('/demo', [DemoController::class, 'index'])->name('demo');
  53. // 主页
  54. Route::get('/', [HomeController::class, 'index'])->name('home');
  55. // 产品路由
  56. Route::prefix('products')->group(function () {
  57. Route::get('/', [ProductController::class, 'index'])->name('products.index');
  58. Route::get('/{id}', [ProductController::class, 'detail'])->name('products.detail');
  59. Route::get('/categories/{categoryId}', [ProductController::class, 'category'])->name('products.category');
  60. });
  61. // 视频路由
  62. Route::prefix('videos')->group(function () {
  63. Route::get('/', [VideoController::class, 'index'])->name('videos.index');
  64. Route::get('/{id}', [VideoController::class, 'detail'])->name('videos.detail');
  65. Route::get('/categories/{categoryId}', [VideoController::class, 'category'])->name('videos.category');
  66. });
  67. // 文章路由
  68. Route::prefix('pages')->group(function () {
  69. Route::get('/', [PageController::class, 'list'])->name('page.list'); // 页面列表页
  70. Route::get('/{slug}', [PageController::class, 'detail'])->name('page.detail'); // 页面详情页
  71. });
  72. ////专题路由,于用文章
  73. //Route::get('/collections/{slug}', [CollectionController::class, 'show'])->name('collections.show');
  74. //
  75. // 询盘路由
  76. Route::prefix('contact')->group(function () {
  77. Route::get('/', [ContactController::class, 'create'])->name('contact.create');
  78. Route::post('/', [ContactController::class, 'store'])->name('contact.store');
  79. });
  80. Route::prefix('collections')->group(function () {
  81. Route::get('/{slug}', [CollectionController::class, 'detail'])->name('collection.detail');
  82. });
  83. // Sitemap 路由
  84. Route::get('/sitemap.xml', [SitemapController::class, 'index'])->name('sitemap.index');