lundi 28 décembre 2015

Tenanti "Undefined variable: Database"

I'm developing an application for multi tenant purpose, for this, I've used Orchestral/Tenanti but I'm experiencing the following problem.

I already performed some of the required steps for Multi Database Connection Setup.

  1. Configuration Tenant Driver for Multiple Database: on my tenanti.php
  2. Setting Default Database Connection: on my Tenant.php Middleware
  3. Definition of my Tenants Connection: on my config/database.php

The problem becomes on the Database Connection Resolver step. In my Middleware I'm defining the connection to be used (I don't post the code because is not relevant for Tenanti use) which is correctly setted.

My resolver code is:

public function boot()
    {
        Tenanti::connection('tenants', function (User $entity, array $template) {
            $template['database'] = "db_{$entity->getKey()}";
            return $template;
        });
    }

This code is located on my AppServiceProvider. But my database to be used, is not correctly setted from my Resolver, throwing the following error:

ErrorException in MySqlConnector.php line 110:
Undefined variable: database

Clearly the error means that database is no setted. Someone can help? Thanks in advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire