rinvex / laravel-attributes

⚠️ [ABANDONED] Rinvex Attributable is a robust, intelligent, and integrated Entity-Attribute-Value model (EAV) implementation for Laravel Eloquent, with powerful underlying for managing entity attributes implicitly as relations with ease. It utilizes the power of Laravel Eloquent, with smooth and seamless integration.
MIT License
433 stars 104 forks source link

setAttribute has not been applied, because there are collisions with other trait methods #80

Closed cord closed 2 years ago

cord commented 5 years ago

am trying to use this nice package within nova in combination Spatie\Translatable.

However combining both traits in the model

class myModel extends Model {

    use \Rinvex\Attributes\Traits\Attributable;
    use \Spatie\Translatable\HasTranslations;

}

causes the error

Trait method setAttribute has not been applied, because there are collisions with other trait methods

Is there any way to work around this situation?

cord commented 5 years ago

Found this on stackoverflow: Collisions with other trait methods

and with some trial & error the following code seems to work

use Rinvex\Attributes\Traits\Attributable as Attributable;
use Rinvex\Support\Traits\HasTranslations as HasTranslations;

class myModel extends Model {
    use Attributable, HasTranslations {
        HasTranslations::setAttribute insteadof Attributable;
    }
}

can you confirm this would be a valid solution?

hcyildirim commented 4 years ago

@cord how did you solve this? I can't make it work.

cord commented 4 years ago

The solution above works here?

hcyildirim commented 4 years ago

The solution above works here?

It does not work for me I guess. Im getting an error that says “id does not exists” when using both translatable and laravel-attributes.

cord commented 4 years ago

Sounds like a different issue to me?

Omranic commented 2 years ago

I confirm the above solution by @cord, that should work for trait collision.