|
@@ -12,6 +12,7 @@ use App\Http\Controllers\CollectionController;
|
|
|
|
|
|
use App\Models\DistProductCategory;
|
|
|
use App\Models\SitePage;
|
|
|
+use App\Models\DistAdminDistributor;
|
|
|
/*
|
|
|
|--------------------------------------------------------------------------
|
|
|
| Web Routes
|
|
@@ -26,36 +27,30 @@ use App\Models\SitePage;
|
|
|
//巴西官网专用路由
|
|
|
$host = $_SERVER['HTTP_HOST']; // 获取当前域名
|
|
|
$uri = $_SERVER['REQUEST_URI']; // 获取当前请求的URI
|
|
|
-if ($host == 'internal-demo-site.mietubl.com.cn') {
|
|
|
+$brHost = 'internal-demo-site.mietubl.com.cn'; // 巴西官网域名
|
|
|
+if ($host == $brHost) {
|
|
|
$segments = explode('/', $uri);
|
|
|
if ($segments) {
|
|
|
- $slug = $segments[0];
|
|
|
- $categoryId = DistProductCategory::where(function ($query) use ($slug) {
|
|
|
- $query->where('slug', $slug);
|
|
|
- })
|
|
|
- ->where('dist_id', getDistId())
|
|
|
- ->first();
|
|
|
-
|
|
|
- if ($categoryId) {
|
|
|
- Route::get('/{categoryId}', [ProductController::class, 'category'])->name('products.category');
|
|
|
+ $slug = $segments[1];
|
|
|
+ if ($slug == 'produto') {
|
|
|
+ Route::get('/produto/{slug}', [ProductController::class, 'detail'])->name('products.detail');
|
|
|
} else {
|
|
|
- $page = SitePage::where('status', '1')->where('dist_id', getDistId())->where('slug', $slug)->first();
|
|
|
- if ($page) {
|
|
|
- return Route::get('/{slug}', [PageController::class, 'detail'])->name('page.detail');
|
|
|
+ $distInfo = DistAdminDistributor::findByDomain($brHost);
|
|
|
+ $categoryId = DistProductCategory::where(function ($query) use ($slug) {
|
|
|
+ $query->where('slug', $slug);
|
|
|
+ })
|
|
|
+ ->where('dist_id', $distInfo->id)
|
|
|
+ ->first();
|
|
|
+ if ($categoryId) {
|
|
|
+ return Route::get('/{categoryId}', [ProductController::class, 'category'])->name('products.category');
|
|
|
+ } else {
|
|
|
+ $page = SitePage::where('status', '1')->where('dist_id', $distInfo->id)->where('slug', $slug)->first();
|
|
|
+ if ($page) {
|
|
|
+ return Route::get('/{slug}', [PageController::class, 'detail'])->name('page.detail');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
- exit;
|
|
|
-
|
|
|
- Route::get('/{slug}', function ($slug) {
|
|
|
- // 查询数据库,将 category_slug 转换为对应ID
|
|
|
-
|
|
|
- });
|
|
|
- Route::get('/produto/{slug}', function ($slug) {
|
|
|
- $productController = new ProductController();
|
|
|
- return $productController->detail($slug);
|
|
|
- });
|
|
|
|
|
|
}
|
|
|
|