php - Manually define db connection in laravel -


I grab the guide explains am Follow the guide and it is all set up how subdomain and correct database Use it to connect. Each tenant will have his own DB and there will also be Master Edin DB. This _admin DB will have a tenant table with subdomain columns. A filter which is not set at all times runs which checks subdomain against tenants table problem is that the database config file master _admin db, which the tenants of the table, but mysql_tenant, where the tenant on the fly Has been set.

I think I have the code to manually connect to the specified DB filter manually, here I have the code for the filter.

  Route: filter ('verify', function ($ route, $ request) {$ host = $ request-> getHost (); $ parts = explosion ('.' , $ host), $ subdomain = $ parts [0]; # ping dB tenant for the match. note that my tenant model Larvel tenant directs the ping table Master dB tenant $ tenant = tenant :: where ( 'Subdomain', '=', $ subdomain) -> First (); # If the tenant database exists but rental in Master DB Doors do not, then redirects to the homepage ($ tenant == NULL) return Redirect :: to ( 'http: //www.'Config :: get (' app.domain '));};  < / Pre> 

I have a line changing:

  $ tenant = tenant :: where ('subdomain', '=', $ subdomain) -> first (); < / code>  

I have tried the following but get an error:

  $ tenant = DB :: connection ( 'mysql') - & gt; tenant :: Where ('subdomain', '=', $ subdomain) -> first ();   

The error I get is:

 < code> Imfoni \ components \ debug \ Exceptions \ FatalErrorException syntax error, unexpected '::' (Tiopiaamaaim_anikeyudioutioiamaim)  on ()  method to specify:   

p>

  $ tenant = tenant :: on ('db_connection') - & gt; Where ('subdomain', '=', $ subdomain) - & gt; First (); Rename your database connection to   

db_connection ( mysql in your example).

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -