-
Notifications
You must be signed in to change notification settings - Fork 225
Trait method newEloquentBuilder has not been applied, because there are collisions with other trait methods #137
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
Comments
Hi @eelco2k, off the top of my head, I believe this is something you will have to resolve locally in your app. Please let me know if you do find a solution, so I can take a look and see if it would be possible to implement in the package. |
as @grimzy commented out in this issue: grimzy/laravel-mysql-spatial#17 he wrote a custom Illuminate\Database\Eloquent\Builder and extending own packages classes with a Trait. Perhaps this would be a good method to do as well for laravel-model-caching. |
i've tried to move the functions in CachedBuilder.php into a Trait but this didn't work sadly. I've also tried this in conjuction with the dev-builder-as-trait branch of the grimzy/laravel-mysql-spatial but i'm still getting the same errors. So no solution yet. |
Yea, I don't think there is an easy solution for this at this time. I'm closing this for now. Please re-open if you have further information that may help out. Thanks for looking into it! |
I had this problem with \Kalnoy\Nestedset\NodeTrait I think this is working as a simple solution in my case, the node trait ran
Looking at the code in the model caching, it was ok to simply override in my model
I would imagine providing the trait that's causing issues doesn't do anything that would cause issues overriding might solve it. Otherwise you'll need to write your own trait to handle the conflict cases I would think. I'm still testing for any side effects... |
@Spodnet Have you found any side effects? |
No issues so far :) |
I've tried @Spodnet solution above, and found that you will be no longer able to use any of \Kalnoy\Nestedset\NodeTrait method, for example, withDepth will no longer be able to use... |
This is still an issue - is there any workaround, now nearly two years later? |
@LiamAird Please open a new issue with full stack trace and query and all the version information. |
@Spodnet @indowebdeveloper @Daniyal-Javani @eelco2k Could you give release 0.10.2 a try and let me know if that fixes the issue? Please see the readme section towards the top regarding conflicting packages as how to implement it. Thanks! |
I tried implementing the fix, but get the error: use GeneaLabs\LaravelModelCaching\ModelCaching;
use Kalnoy\Nestedset\QueryBuilder;
class AppServiceProvider extends ServiceProvider
{
public function register()
{
//
}
public function boot()
{
ModelCaching::useBuilder(QueryBuilder::class);
} |
Can you make sure you got the latest update, change your composer json to
then run |
@mikebronner Its already at that version. |
Hmmm, ok. Leave it at release 0.10.1 for now, I'm working on an update to this functionality and hope to release it in the next day or so. |
Issue
Trait method newEloquentBuilder has not been applied, because there are collisions with other trait methods on App\Models\Flight.
I found out that i'm also using \Grimzy\LaravelMysqlSpatial Trait in this model.
and reading this issue it looks like it has to do with this package.
grimzy/laravel-mysql-spatial#17
I'm not sure if it's possible to implement a method to fix this issue in this package or that i do have to create my own custom "Illuminate\Database\Eloquent\Builder".
Environment
Laravel Version: 5.5.40
Laravel Model Caching Package Version: 0.2.62
PHP Version: PHP 7.1.8
Operating System & Version: Mac OS X
Stack Trace
The text was updated successfully, but these errors were encountered: