Skip to content
This repository has been archived by the owner on Jan 9, 2024. It is now read-only.

Search doesn't work with with or load #108

Open
vanvanni opened this issue Jul 29, 2020 · 2 comments
Open

Search doesn't work with with or load #108

vanvanni opened this issue Jul 29, 2020 · 2 comments

Comments

@vanvanni
Copy link

I want to load in my relation when using search but I cannot use the with() method. I have been searching around for solutions and people starting to use load() but that is also not available.

What options do I have left here?

@sbreiler
Copy link

Hi, i just came across the same problem, i got it down to:

        $search = [
            'term' => $request->input('term', '')
        ];

        if( $search['term'] ) {
            $list = MyModel::search($search['term'])->query(function($builder) {
                /** @var \Illuminate\Database\Eloquent\Builder $builder */
                $builder
                    ->with('latestAudit');
            });
        }
        else {
            $list = MyModel::with('latestAudit');
        }

        $list = $list->paginate(20);

Not pretty, but it works for me.

@sbreiler
Copy link

Ah... i just saw it wont work, see #102

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants