<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Models\Product;

class SearchController extends Controller
{
    public function search(Request $request)
    {
        // 取得搜尋關鍵字
        $query = $request->input('product_search');
        
        // 查詢產品
        $products = Product::search($request->search=$query)->get();

        // 將結果傳遞到 Blade View
        return view('search.products.show', compact('products'));
    }
}
