mikebronner / laravel-model-caching

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

Trait method 'newBelongsToMany' will not be applied, because it collides with 'ExtendRelationsTrait' #365

Closed Sakvojage closed 3 years ago

Sakvojage commented 3 years ago

Issue

Trait method 'newBelongsToMany' will not be applied, because it collides with 'ExtendRelationsTrait'

namespace App\Models;

use App\BlamableTrait;
use App\HasLogsTrait;
use App\IndexConfigurators\DeviceIndexConfigurator;
use GeneaLabs\LaravelModelCaching\Traits\Cachable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOne;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Notifications\Notifiable;
use ScoutElastic\Searchable;

class Device extends Model
{
    use Searchable, SoftDeletes, Notifiable, BlamableTrait, HasLogsTrait, AuthorizesRequests, Cachable;

Environment

Laravel Version: 7.25.0 Laravel Model Caching Package Version: 0.10.1 PHP Version: 7.4.9 Operating System & Version: 7.4.9

mikebronner commented 3 years ago

@Sakvojage Thanks for reporting this. Can you provide more information as to where you are seeing this error? If this is PHPStorm reporting this in the editor, it is likely a bug in PHPStorm, see #354

mikebronner commented 3 years ago

I'll close this issue for now. Please re-open if the above isn't what you meant. :)

Sakvojage commented 3 years ago

It doesn't seem to be a PHPStorm problem - if I try to use Cachable on any of my models I get this warning and GitLab CI/CD crashes during the test stage (with segmentation fault). It seems weird, that I am the only one with this problem as project is quite generic and has no custom Models or vendor packages.

image

Sakvojage commented 3 years ago

Current composer.json image

mikebronner commented 3 years ago

@Sakvojage Unfortunately I am unable to reproduce this issue, and all tests are successful. So far I have seen no evidence that this is a problem with this package. If you could provide a full stack trace that shows this issue occurring, that would help troubleshoot the issue.

Sakvojage commented 3 years ago

Ok, I've just tried this with fresh and empty Laravel and Laradock install.

composer require genealabs/laravel-model-caching
php artisan modelCache:publish --config
php artisan make:model Product

Then add use Cachable to Product model - still get this collision. However MS Visual Studio Code has no problem with it. Weird. I go blame JetBrains then.