43 lines
1.3 KiB
PHP
43 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Web\Product;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Services\Product\ProductService;
|
|
use Illuminate\Http\Request;
|
|
|
|
class ProductController extends Controller
|
|
{
|
|
public function __construct(protected ProductService $service) {}
|
|
|
|
public function index(Request $request, $category = null)
|
|
{
|
|
$search = $request->query('search'); // ?search=키워드 추출
|
|
$data = $this->service->getListSceneData($category, $search);
|
|
|
|
return view('web.product.list.index', [
|
|
'pageTitle' => $data['currentCategoryName'],
|
|
'subnavItems' => $data['menuItems'],
|
|
'subnavActive' => null, // 검색 시에는 사이드바 활성화 해제 권장
|
|
'products' => $data['products'],
|
|
'searchKeyword' => $search
|
|
]);
|
|
}
|
|
|
|
public function show(int $id)
|
|
{
|
|
$data = $this->service->getProductDetailData($id);
|
|
|
|
if (!$data) abort(404);
|
|
|
|
return view('web.product.detail.index', [
|
|
'product' => $data['product'],
|
|
'skus' => $data['skus'],
|
|
'payments' => $data['payments'],
|
|
'subnavItems' => $data['menuItems'],
|
|
'subnavActive' => $data['product']->category_id,
|
|
'pageTitle' => $data['product']->name,
|
|
]);
|
|
}
|
|
}
|