Answers for "laravel search inside array column"

PHP
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

Code answers related to "laravel search inside array column"

Browse Popular Code Answers by Language