Fixes for implicit casting
This commit is contained in:
parent
2b01086d9f
commit
cf2dadc22f
|
|
@ -33,13 +33,15 @@ class TokenAuth
|
|||
public function handle($request, Closure $next)
|
||||
{
|
||||
|
||||
if ($request->header('X-API-TOKEN') && ($company_token = CompanyToken::with([
|
||||
if (config('ninja.db.multi_db_enabled') &&
|
||||
$request->header('X-API-TOKEN') &&
|
||||
($company_token = MultiDB::getCompanyToken($request->header('X-API-TOKEN')))) {
|
||||
} elseif ($request->header('X-API-TOKEN') && ($company_token = CompanyToken::with([
|
||||
'user.account',
|
||||
'company',
|
||||
'account',
|
||||
'cu',
|
||||
'cu'
|
||||
])->where('token', $request->header('X-API-TOKEN'))->first())) {
|
||||
|
||||
} else {
|
||||
return response()->json(['message' => 'Invalid token'], 403);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -336,6 +336,7 @@ class MultiDB
|
|||
'user.account',
|
||||
'company',
|
||||
'account',
|
||||
'cu'
|
||||
])->where('token', $token)->first()) {
|
||||
|
||||
self::setDB($db);
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ class CompanyGateway extends BaseModel
|
|||
}
|
||||
|
||||
/* This is the public entry point into the payment superclass */
|
||||
public function driver(Client $client = null)
|
||||
public function driver(?Client $client = null)
|
||||
{
|
||||
// $class = static::driver_class();
|
||||
$class = self::driver_class();
|
||||
|
|
|
|||
|
|
@ -95,7 +95,6 @@ class CompanyToken extends BaseModel
|
|||
return $this->hasOne(CompanyUser::class, ['user_id', 'company_id'], ['user_id', 'company_id']);
|
||||
}
|
||||
|
||||
|
||||
// public function company_user(): \Illuminate\Database\Eloquent\Relations\HasOne
|
||||
// {
|
||||
// return $this->hasOne(CompanyUser::class, 'user_id', 'user_id')
|
||||
|
|
|
|||
|
|
@ -234,12 +234,16 @@ class User extends Authenticatable implements MustVerifyEmail
|
|||
return $truth->getCompanyToken();
|
||||
}
|
||||
|
||||
// if (request()->header('X-API-TOKEN')) {
|
||||
if (request()->header('X-API-TOKEN')) {
|
||||
return CompanyToken::with(['cu'])->where('token', request()->header('X-API-TOKEN'))->first();
|
||||
|
||||
$token = CompanyToken::with(['cu'])->where('token', request()->header('X-API-TOKEN'))->first();
|
||||
if ($token) {
|
||||
return $token;
|
||||
}
|
||||
|
||||
return $this->tokens()->first();
|
||||
}
|
||||
|
||||
return $this->tokens()->with(['cu'])->first();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue