Support the ongoing development of Laravel.io →
Configuration Input Database
Last updated 2 years ago.
0

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

0

Sign in to participate in this thread!

Eventy

Your banner here too?

ckahle33 ckahle33 Joined 15 Dec 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.