123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
- use Illuminate\Support\Facades\Route;
- use App\Http\Controllers\HomeController;
- use App\Http\Controllers\ProductController;
- use App\Http\Controllers\PageController;
- use App\Http\Controllers\ContactController;
- use App\Http\Controllers\VideoController;
- use App\Http\Controllers\DemoController;
- use App\Http\Controllers\SitemapController;
- use App\Http\Controllers\CollectionController;
- use App\Models\DistProductCategory;
- use App\Models\SitePage;
- /*
- |--------------------------------------------------------------------------
- | Web Routes
- |--------------------------------------------------------------------------
- |
- | Here is where you can register web routes for your application. These
- | routes are loaded by the RouteServiceProvider and all of them will
- | be assigned to the "web" middleware group. Make something great!
- |
- */
- //巴西官网专用路由
- $host = $_SERVER['HTTP_HOST']; // 获取当前域名
- if ($host == 'internal-demo-site.mietubl.com.cn') {
- Route::get('/{slug}', function ($slug) {
- // 查询数据库,将 category_slug 转换为对应ID
- $categoryId = DistProductCategory::where(function ($query) use ($slug) {
- $query->where('slug', $slug);
- })
- ->where('dist_id', getDistId())
- ->first();
- if ($categoryId) {
- return ProductController::category($slug);
- } else {
- $page = SitePage::where('status', '1')->where('dist_id', getDistId())->where('slug', $slug)->first();
- if ($page) {
- return PageController::detail($page);
- }
- }
- });
- Route::get('/produto/{slug}', function ($slug) {
- return ProductController::detail($slug);
- });
- }
- Route::get('/demo', [DemoController::class, 'index'])->name('demo');
- // 主页
- Route::get('/', [HomeController::class, 'index'])->name('home');
- // 产品路由
- Route::prefix('products')->group(function () {
- Route::get('/', [ProductController::class, 'index'])->name('products.index');
- Route::get('/{id}', [ProductController::class, 'detail'])->name('products.detail');
- Route::get('/categories/{categoryId}', [ProductController::class, 'category'])->name('products.category');
- });
- // 视频路由
- Route::prefix('videos')->group(function () {
- Route::get('/', [VideoController::class, 'index'])->name('videos.index');
- Route::get('/{id}', [VideoController::class, 'detail'])->name('videos.detail');
- Route::get('/categories/{categoryId}', [VideoController::class, 'category'])->name('videos.category');
- });
- // 文章路由
- Route::prefix('pages')->group(function () {
- Route::get('/', [PageController::class, 'list'])->name('page.list'); // 页面列表页
- Route::get('/{slug}', [PageController::class, 'detail'])->name('page.detail'); // 页面详情页
- });
- ////专题路由,于用文章
- //Route::get('/collections/{slug}', [CollectionController::class, 'show'])->name('collections.show');
- //
- // 询盘路由
- Route::prefix('contact')->group(function () {
- Route::get('/', [ContactController::class, 'create'])->name('contact.create');
- Route::post('/', [ContactController::class, 'store'])->name('contact.store');
- });
- Route::prefix('collections')->group(function () {
- Route::get('/{slug}', [CollectionController::class, 'detail'])->name('collection.detail');
- });
- // Sitemap 路由
- Route::get('/sitemap.xml', [SitemapController::class, 'index'])->name('sitemap.index');
|