The search feature is not working after I deployed my website but it is working on my localhost. In the first picture, I am able to search for anything on my localhost and able to query any data I want. But after I deploy it online, the search feature is not working
here is the full code:
@if($products -> isEmpty())
<h3 class="text-center text-danger">Product not found</h3>
@else
<div class="container mt-5">
<div class="row d-flex justify-content-center ">
<div class="col-md-6">
<div class="card">
@foreach($products as $item)
<a href="{{ url('product/details/'.$item->id.'/'.$item->product_slug_en ) }}">
<div class="list border-bottom">
<img src="{{asset($item->product_thambnail)}}" style="padding-right: 10px; width: 120px; height: 60px; border-right: 2px solid #eee;">
<div class="d-flex flex-column ml-3" style="margin-left: 10px;">
<span>{{$item->product_name_en}}</span>
<small style="margin-left: 5px;">₱{{$item->selling_price}}</small>
</div>
</div>
</a>
@endforeach
</div>
</div>
</div>
</div>
@endif
jQuery("[data-toggle='tooltip']").tooltip();
const site_url = "http://127.0.0.1:8000/";
$("body").on("keyup", "#search", function(e){
let text = $("#search").val();
if (text.length>0){
$.ajax({
data : {search: text},
url : site_url + "search-product",
method : 'post',
beforSend: function(request){
return request.setRequestHeader('X-CSRF-token',("meta[name='csrf-token']"))
},
success:function(result){
$("#searchProducts").html(result)
}
});
}if(text.lengh<1){
$("#searchProducts").html("");
}
});
public function SearchProduct(Request $request)
{
$request->validate(["search" => "required"]);
$item = $request->search;
$products = Product::where('product_tags_en', 'LIKE', "%$item%")
->orwhere('product_color_en', 'LIKE', "%$item%")
->orwhere('product_name_en', 'LIKE', "%$item%")
->select('product_name_en', 'product_thambnail', 'selling_price', 'id', 'product_slug_en')
->get();
return view('frontend.product.search_product', compact('products'));
}
}
