|
@@ -1,5 +1,4 @@
|
|
|
<?php
|
|
|
-
|
|
|
use Illuminate\Support\Facades\Route;
|
|
|
|
|
|
use App\Http\Controllers\HomeController;
|
|
@@ -11,6 +10,9 @@ use App\Http\Controllers\DemoController;
|
|
|
use App\Http\Controllers\SitemapController;
|
|
|
use App\Http\Controllers\CollectionController;
|
|
|
|
|
|
+use App\Models\DistProductCategory;
|
|
|
+use App\Models\SitePage;
|
|
|
+use App\Models\DistAdminDistributor;
|
|
|
/*
|
|
|
|--------------------------------------------------------------------------
|
|
|
| Web Routes
|
|
@@ -21,6 +23,40 @@ use App\Http\Controllers\CollectionController;
|
|
|
| be assigned to the "web" middleware group. Make something great!
|
|
|
|
|
|
|
*/
|
|
|
+
|
|
|
+//巴西官网专用路由
|
|
|
+$host = request()->getHttpHost(); // 安全且可靠
|
|
|
+$uri = request()->getRequestUri();
|
|
|
+$brHost = env('BR_HOST'); // 巴西官网域名
|
|
|
+if ($host == $brHost) {
|
|
|
+ $segments = explode('/', $uri);
|
|
|
+ if ($segments) {
|
|
|
+ $slug = $segments[1];
|
|
|
+ if ($slug == 'produto') {
|
|
|
+ Route::get('/produto/{slug}', [ProductController::class, 'detail'])->name('products.detail');
|
|
|
+ } else {
|
|
|
+ $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');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
Route::get('/demo', [DemoController::class, 'index'])->name('demo');
|
|
|
|
|
|
|
|
@@ -63,3 +99,8 @@ Route::prefix('collections')->group(function () {
|
|
|
|
|
|
// Sitemap 路由
|
|
|
Route::get('/sitemap.xml', [SitemapController::class, 'index'])->name('sitemap.index');
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|