Server : Apache System : Linux host44.registrar-servers.com 4.18.0-513.18.1.lve.2.el8.x86_64 #1 SMP Sat Mar 30 15:36:11 UTC 2024 x86_64 User : vapecompany ( 2719) PHP Version : 7.4.33 Disable Function : NONE Directory : /proc/thread-self/root/home/vapecompany/demo.vapecompany.com.bd/app/Http/Controllers/Frontend/ |
Upload File : |
<?php namespace App\Http\Controllers\Frontend; use App\Http\Controllers\Controller; use App\Models\Category; use App\Models\Product; use Illuminate\Http\Request; class SearchController extends Controller { public function search(Request $request){ if($request->category){ $products = Product::where('product_name', 'like','%' .$request->search. '%')->where('category_id', $request->category)->orderBy('product_id','DESC')->paginate(12); }else{ $products = Product::where('product_name', 'like','%' .$request->search. '%')->orderBy('product_id','DESC')->paginate(16); } return view('frontend.pages.search', compact('products')); } // Category wise product show public function categoryWiseSearch($id){ $products = Product::where('category_id', $id)->orderBy('product_id','DESC')->paginate(12); return view('frontend.pages.search', compact('products')); } }