hipsterjazzbo / Landlord

A simple, single database multi-tenancy solution for Laravel 5.2+
MIT License
614 stars 138 forks source link

Eloquent ORM #18

Closed bauersfeld closed 8 years ago

bauersfeld commented 8 years ago

Great work on Landlord, however, it does not seem to work with ORM relationships.

My member model has a tenant column called site_id. I have a another model called Profile that has a relationship to Member, but no site_id.

I'm calling Landlord::addTenant('site_id', $data['siteId']) in my middleware.

class Member extends Model
{
    use BelongsToTenant;
}

class Profile extends Model
{
    public function member()
    {
        return $this->hasOne('Models\Member');
    }
}

If I tried to find a record using a profile id, the Landlord tenant code does not protect the reference to member.

$profile = Profile::find(1)

$profile->member  // returns the member record regardless of the tenant column set.

Am I missing something or is there a way to address this?

bauersfeld commented 8 years ago

Problem solved. Typo on my side. thx for the great code!

tnorthcutt commented 8 years ago

@bauersfeld could you close this since it's a non-issue?