Hi
This one is difficult to communicate - I can paste code examples here but let's see how we go without them first.
I'm trying (yet another) approach to multi tenancy. The approach I am taking is -
- Modify the auth filter to create a tenant context in (just like Culttt - but I just use the set and id methods of his repo)
- Use TenantScopeTrait in my model(s) which is just a global scope and borrow very heavily from the Laravel SoftDeletingTrait - the only difference, of course is that rather than looking for null (or not null, as the case may be) deleted_at columns, I am looking for tenant_id = static::$tenantContext->id()
- In that TenantScopeTrait, I use public static function boot() to access the $tenantContext (shared) object, which you'll recall is created when the auth filter is run
There is not much more to it. It is really simple and I like this approach. Using Codeception, my acceptance tests pass, my functional tests do not.
As data separation is important here, I really do need to get functional testing up and running - I am keen to peek into the database to make sure I have separated the data properly.
The error I get is
Couldn't click "Create":
ErrorException: Trying to get property of non-object
Scenario Steps:
5. I click "Create"
4. I fill field "password","password"
3. I fill field "email","joe@email.com"
2. I am on page "http://demo.domain.app/login"
1. As a user
... or ...
Can't be on page "http://demo.domain.app/clients":
ErrorException: Trying to get property of non-object
Scenario Steps:
3. I am on page "http://demo.domain.app/clients"
2. I am logged as "{"id":"2","tenant_id":"1","client_id":null,"fname":"Joe","lname":"Bloggs","email":"joe@email.com","created_at":"2014-08-21 15:26:11","updated_at":"2014-08-21 16:28:17","deleted_at":null}"
1. As a user
... depending on which approach I use to login with Codeception. They are the same outcome using two different methods to login.
Do you have any ideas where I might start looking? I can provide code examples if need be.
Thanks for reading and apologies for such a ... well ... generic question.