Fix DB search

This commit is contained in:
David Bomba 2019-09-23 22:19:37 +10:00
parent 3ad0a3ff9a
commit bbabe4836b
3 changed files with 6 additions and 4 deletions

View File

@ -33,6 +33,7 @@ class InvitationController extends Controller
{ {
$invitation = InvoiceInvitation::whereInvitationKey($invitation_key)->first(); $invitation = InvoiceInvitation::whereInvitationKey($invitation_key)->first();
// $invitation = InvoiceInvitation::whereRaw("BINARY `invitation_key`= ?", [$invitation_key])->first();
if($invitation){ if($invitation){
$invitation->markViewed(); $invitation->markViewed();

View File

@ -26,13 +26,12 @@ class SetDomainNameDb
public function handle($request, Closure $next) public function handle($request, Closure $next)
{ {
$error['error'] = ['message' => 'Database could not be set']; $error['error'] = ['message' => 'Database could not be set'];
/* /*
* Use the host name to set the active DB * Use the host name to set the active DB
**/ **/
if( $request->getHttpHost() && config('ninja.db.multi_db_enabled') && ! MultiDB::findAndSetDbByDomain($request->getHttpHost())) if( $request->getSchemeAndHttpHost() && config('ninja.db.multi_db_enabled') && ! MultiDB::findAndSetDbByDomain($request->getSchemeAndHttpHost()))
{ {
if(request()->json) if(request()->json)
return response()->json(json_encode($error, JSON_PRETTY_PRINT) ,403); return response()->json(json_encode($error, JSON_PRETTY_PRINT) ,403);

View File

@ -143,13 +143,15 @@ class MultiDB
public static function findAndSetDbByDomain($domain) :bool public static function findAndSetDbByDomain($domain) :bool
{ {
\Log::error("searching for {$domain}");
foreach (self::$dbs as $db) foreach (self::$dbs as $db)
{ {
$company = Company::on($db)->whereDomain($domain)->first();
\Log::error($company);
if($company = Company::on($db)->whereDomain($domain)->first()) if($company = Company::on($db)->whereDomain($domain)->first())
{ {
\Log::error("setting db");
self::setDb($company->db); self::setDb($company->db);
return true; return true;