public function search()
{
$search = request()->input('search');
$products = DB::table('products')
->whereRaw("LOWER(JSON_EXTRACT(name, "$.".app()->getLocale()."")) LIKE ?", ["%".strtolower($search)."%"])
->whereNull('deleted_at')
->select(['id', 'name', 'slug',])
->orderBy('id', 'desc')
->limit(15)->get()->transform(function ($product) {
$data = collect($product)->toArray();
return new ProductSearchViewModel($data);
});
return JsonReturnViewModel::toJsonBeautify($products);
}