Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel Scout integration #9

Open
mucskaati opened this issue Apr 12, 2022 · 0 comments
Open

Laravel Scout integration #9

mucskaati opened this issue Apr 12, 2022 · 0 comments

Comments

@mucskaati
Copy link

mucskaati commented Apr 12, 2022

Hello,

I have got an issue when I try to integrate Laravel Scout to model which also has integrated yours EagerLoadPivotTrait.
$recipes = Recipe::with('foodmenus')->search($request->search)->whereHas('foodmenus', function (Builder $query) use ($clientPrograms) { $query->whereIn('id', $clientPrograms); $query->latest(); })->get();

When this code block is executing I got an error:
Call to undefined method AjCastro\\EagerLoadPivotRelations\\EagerLoadPivotBuilder::search()

In Recipe model I use these traits:

<?php

namespace App\Models;

use App\Services\Foodmenus\NutritionCalculator;
use Illuminate\Database\Eloquent\Model;
use DateTimeInterface;
use Brackets\Media\HasMedia\ProcessMediaTrait;
use Brackets\Media\HasMedia\AutoProcessMediaTrait;
use Brackets\Media\HasMedia\HasMediaCollectionsTrait;
use Spatie\MediaLibrary\HasMedia;
use Spatie\MediaLibrary\MediaCollections\Models\Media;
use Brackets\Media\HasMedia\HasMediaThumbsTrait;
use Carbon\Carbon;
use AjCastro\EagerLoadPivotRelations\EagerLoadPivotTrait;
use Laravel\Scout\Searchable;

class Recipe extends Model implements HasMedia
{
    use Searchable;
    use ProcessMediaTrait;
    use AutoProcessMediaTrait;
    use HasMediaCollectionsTrait;
    use HasMediaThumbsTrait;
    use EagerLoadPivotTrait;
...

Can you please tell me what cause this issue and how to solve it?

Thanks.

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

No branches or pull requests

1 participant