fixed default company identification
caused by https://github.com/laravel/framework/pull/42942
This commit is contained in:
@ -26,9 +26,7 @@ class IdentifyCompany
|
||||
{
|
||||
$this->request = $request;
|
||||
|
||||
$company_id = $this->request->isApi()
|
||||
? $this->getCompanyIdFromApi()
|
||||
: $this->getCompanyIdFromWeb();
|
||||
$company_id = $this->getCompanyId();
|
||||
|
||||
if (empty($company_id)) {
|
||||
abort(500, 'Missing company');
|
||||
@ -60,6 +58,19 @@ class IdentifyCompany
|
||||
return $next($this->request);
|
||||
}
|
||||
|
||||
protected function getCompanyId()
|
||||
{
|
||||
if ($company_id = company_id()) {
|
||||
return $company_id;
|
||||
}
|
||||
|
||||
if ($this->request->isApi()) {
|
||||
return $this->getCompanyIdFromApi();
|
||||
}
|
||||
|
||||
return $this->getCompanyIdFromWeb();
|
||||
}
|
||||
|
||||
protected function getCompanyIdFromWeb()
|
||||
{
|
||||
return $this->getCompanyIdFromRoute() ?: ($this->getCompanyIdFromQuery() ?: $this->getCompanyIdFromHeader());
|
||||
@ -86,4 +97,4 @@ class IdentifyCompany
|
||||
{
|
||||
return (int) $this->request->header('X-Company');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user