neat-php / object

Neat Object components
MIT License
4 stars 1 forks source link

Relations trait getters and setters #33

Closed annavanbiemen closed 3 years ago

annavanbiemen commented 4 years ago

It would be great to add automatic support for get and set methods using magic __call method in the relations trait.

This way you'll only have to add @method docblocks in the class definiation of your entity/model to have code completion support in your IDE from interaction with your models.

/**
 * @method Role getRole()
 * @method void setRole(Role $role)
 */
class User
{
    use Relations;

    public function role(): One
    {
         return $this->belongsToOne(Role::class);
    }
}