Answers for "Builder $query laravel search array"

PHP
1

laravel query builder get data as array of array

$array = get_object_vars($result);
Posted by: Guest on March-15-2021
0

search query in laravel

$searchTerm ='milad zamir Abc';
$reservedSymbols = ['-', '+', '<', '>', '@', '(', ')', '~'];
$searchTerm = str_replace($reservedSymbols, ' ', $searchTerm);

$searchValues = preg_split('/\s+/', $searchTerm, -1, PREG_SPLIT_NO_EMPTY);

$res = User::where(function ($q) use ($searchValues) {
	foreach ($searchValues as $value) {
    $q->orWhere('name', 'like', "%{$value}%");
    $q->orWhere('family_name', 'like', "%{$value}%");
    }
})->get();
Posted by: Guest on November-08-2020

Code answers related to "Builder $query laravel search array"

Browse Popular Code Answers by Language