How about this code modification result:
public function scopeEventSearch($query, $search) {
if ($search != null) {
$searchTerms = explode(' ', $search);
$query->where(function($q) use ($term,$searchTerms) {
foreach($searchTerms as $term) {
$q->orWhere('event_name', 'LIKE', '%'. $term .'%')
->orWhere('venue_name', 'LIKE', '%'. $term .'%')
->orWhere('address', 'LIKE', '%'. $term .'%')
->orWhere('city', 'LIKE', '%'. $term .'%')
->orWhere('state', 'LIKE', '%'. $term .'%')
->orWhere('zip', 'LIKE', '%'. $term .'%')
->orWhere('description', 'LIKE', '%'. $term .'%')
->orWhereHas('categories', function($c) use ($term) {
$c->where('name', 'LIKE', '%'. $term .'%');
});
});
}
}
return $query;
}
if still same or error (i have no time to test the modification code), please wait for next answers. #cmiiw
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community