Answers for "search in array laravel"

PHP
2

laravel where in array

$items = Item::whereIn('id', [1,2,..])->get();
Posted by: Guest on May-01-2021
1

laravel where in array

$items = DB::table('items')->whereIn('id',[1,2,..])->get();
Posted by: Guest on September-24-2020
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
0

laravel where in array

$items = Item::whereIn('id', [1,2,..])->get();
Posted by: Guest on September-24-2020
0

laravel search inside array column

Solution1: ->whereJsonContains('user_id', 3)
  
Solution2: ->whereRaw("JSON_CONTAINS(user_id, '[3]' )")
  
Solution3: ->where('user_id','like',"%{$id}%")
 
Solution4: Person::hasJob($job->id);
// Inside Model
public function scopeHasJob($query, $jobId)
{
    return $query->where('user_id', 'like', "%\"{$userId}\"%");
}
Posted by: Guest on July-08-2021

Browse Popular Code Answers by Language