<?php

use Illuminate\Support\Facades\Route;
use App\Http\Controllers\Marketplace\CartController;
use App\Http\Controllers\Marketplace\ReviewController;
use App\Http\Controllers\Marketplace\ProductViewController;
use App\Http\Controllers\Marketplace\StoreController;
use App\Http\Controllers\Marketplace\SearchController; 
use App\Http\Controllers\Marketplace\CategoryViewController;
use App\Http\Controllers\Marketplace\DealController; 

/*
|--------------------------------------------------------------------------
| Public Marketplace Routes
|--------------------------------------------------------------------------
| Everyone (Guests & Logged In users) can access these routes.
*/

// Product & Category Views
Route::get('/product-view/{slug_id}', [ProductViewController::class, 'show'])->name('product.view');
Route::get('/category/{slug}', [CategoryViewController::class, 'show'])->name('category.show');
Route::get('/store/{slug}', [StoreController::class, 'show'])->name('store.view');

// Search & Deals
Route::get('/search/suggestions', [SearchController::class, 'suggestions'])->name('search.suggestions');
Route::get('/search', [SearchController::class, 'index'])->name('search.index');
Route::get('/super-deals', [DealController::class, 'index'])->name('deals.index');


/*
|--------------------------------------------------------------------------
| Authenticated Marketplace Routes
|--------------------------------------------------------------------------
| Only logged-in users can access these routes (Cart, Reviews).
*/
Route::middleware(['auth', 'verified'])->prefix('marketplace')->name('marketplace.')->group(function () {
    
    // Cart Routes
    Route::get('/cart', [CartController::class, 'index'])->name('cart.index');
    Route::post('/cart', [CartController::class, 'store'])->name('cart.store');
    Route::put('/cart/{cart}', [CartController::class, 'update'])->name('cart.update');
    Route::delete('/cart/{cart}', [CartController::class, 'destroy'])->name('cart.destroy');

    // Review Routes
    Route::post('/product/{product}/reviews', [ReviewController::class, 'store'])->name('reviews.store');

});