IsraelOrtuno / Eavquent

EAV modeling package for Laravel and Eloquent – This package is abandoned, please use this fork https://github.com/rinvex/attributes
63 stars 13 forks source link

Remove __call method from trait (breaking change) #49

Closed lioreshai closed 6 years ago

lioreshai commented 7 years ago

Defining a call method in the trait opens up the application to the possibility of conflicts. If any other trait wants to use the call method, the a fatal error is fired due to collision.

I think it would be better to override __call in the model using the Eavquent trait, so you leave open the possibility of packages other than Eavquent using magic methods as well.

This is a breaking change, and models using Eavquent would need to be updated with the following method:

public function __call($method, $parameters)
    {
        if($eav_call = $this->eavquentMagicMethodCall($method,$parameters)) return $eav_call;

        //if($other_package_call = $this->otherPackageMagicMethodCall($method,$parameters)) return $other_package_call;
        return parent::__call($method, $parameters);
    }

Please let me know your thoughts

IsraelOrtuno commented 7 years ago

I really like this improvement. Will have it into account, package is currently being entirely rewritten :)

lioreshai commented 7 years ago

Sounds good I'm looking forward to it. Happy to contribute to the rewritten package as well.

IsraelOrtuno commented 7 years ago

I will leave it open as I like it and do not want to forget