Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel json search

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);
    }
Comment

PREVIOUS NEXT
Code Example
Php :: smtp php test 
Php :: how to recover xampp deleted files 
Php :: laravel migration two primary key 
Php :: laravel 8 change password 
Php :: make model with migration laravel 
Php :: laravel withHas 
Php :: php needle haystack 
Php :: change returning datetime timezone to recalculate with user timezone laravel 
Php :: php add to array in loop 
Php :: php imap install 
Php :: write in a file using php 
Php :: laravel database select 
Php :: get full current url in laravel 
Php :: wordpress plugin add stylesheet 
Php :: larave artisan command run in web 
Php :: laravel tinker generate password 
Php :: woocommerce bulk product delete 
Php :: how to get local current time in laravel 
Php :: for each loop syntax in laravel 
Php :: install laravel 
Php :: check current pages is a child page wordpress 
Php :: php check request method 
Php :: password_hash 
Php :: only display part of string php 
Php :: php fpm config file location 
Php :: separate numbers with commas laravel 
Php :: php mysqli fetch single row 
Php :: get country from clouflare 
Php :: laravel run migration specific file 
Php :: wordpress get paragraph of content 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =