darya/framework

Optionally define Record relationships using methods

Opened this issue · 0 comments

hexus commented

Similar to the way Laravel does it, though this will bulk out the class even more.

class User extends Record
{
    public function roles() {
        return $this->belongsToMany('Role')->table('user_roles');
    }

    public function things() {
        return $this->hasMany('Thing')->foreignKey('owner_id');
    }
}