lundi 28 janvier 2019

Use more complex where clauses in Scout

I am a happy user of Laravel Scout.

Now I'd like to extend my search:

        $data
            = new UserOverviewResourceCollection(User::search($searchphrase)
            ->currentStatus('active')->orderBy('lastname', 'asc')
            ->orderBy('firstname', 'asc')
            ->paginate(config('pagination.length')));

currentStatus comes from https://github.com/spatie/laravel-model-status .

Now I am getting a response, that currentStatus is not supported. I thought I could be a good idea to filter the result of User::search after it has been returned from scout?

Another idea: I'd like to add more complex where clauses:

->where([
                [
                    'starts_on',
                    '<',
                    Carbon::now()->toDateTimeString(),
                ],
                [
                    'ends_on',
                    '>',
                    Carbon::now()->toDateTimeString(),
                ],
            ])

Maybe you got a better idea?



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2DDjXYB
via IFTTT

Aucun commentaire:

Enregistrer un commentaire