laravel search inside array column

Solutions on MaxInterview for laravel search inside array column by the best coders in the world

showing results for - "laravel search inside array column"
Enrico
06 Jun 2018
1Solution1: ->whereJsonContains('user_id', 3)
2  
3Solution2: ->whereRaw("JSON_CONTAINS(user_id, '[3]' )")
4  
5Solution3: ->where('user_id','like',"%{$id}%")
6 
7Solution4: Person::hasJob($job->id);
8// Inside Model
9public function scopeHasJob($query, $jobId)
10{
11    return $query->where('user_id', 'like', "%\"{$userId}\"%");
12}
13
14