mikebronner / laravel-model-caching

Eloquent model-caching made easy.
MIT License
2.24k stars 214 forks source link

Could not check compatibility newBelongsToMany #369

Closed marechenok closed 3 years ago

marechenok commented 3 years ago

Describe the bug WIth php 7.4 got this error, 7.3 seems ok. Php 7.4 with 0.10.1 --> ok

Eloquent Query Try using any model with Cachable trait.

$model->with('otherModel')->get();

Stack Trace Could not check compatibility between GeneaLabs\LaravelModelCaching\Traits\Cachable::newBelongsToMany(GeneaLabs\LaravelModelCaching\EloquentBuilder $query, Illuminate\Database\Eloquent\Model $parent, $table, $foreignPivotKey, $relatedPivotKey, $parentKey, $relatedKey, $relationName = NULL) and Illuminate\Database\Eloquent\Model::newBelongsToMany(Illuminate\Database\Eloquent\Builder $query, Illuminate\Database\Eloquent\Model $parent, $table, $foreignPivotKey, $relatedPivotKey, $parentKey, $relatedKey, $relationName = NULL), because class GeneaLabs\LaravelModelCaching\EloquentBuilder is not available

Environment

mikebronner commented 3 years ago

@marechenok please provide the full stack trace.

mpanius commented 3 years ago

It seems, that it is declaration incompatibility with your package laravel-pivot-events 'Trait method 'newBelongsToMany' will not be applied, because it collides with 'ExtendRelationsTrait' - that's what i see in phpstorm errors reporting.

But i don't use belongsToMany at this project, so can't give you full stacktrace.

marechenok commented 3 years ago

I've this error only on staging env while running tests in CI/CD pipeline, so I can't give you any traces. Downgrade to 0.10.1 fixes problem for now.

mikebronner commented 3 years ago

So at this point I'm not sure where this error is being seen. All the unit tests are passing. If you are seeing this in PHPStorm, this is a bug there: #354. I will close this for now, as I am unable to recreate with the information given. If you are able to provide more information, please do respond here and I will re-open if I am able to recreate the issue.