improved tenant identification
This commit is contained in:
@ -72,7 +72,7 @@ class Modules
|
||||
|
||||
public static function getPaymentMethodsCacheKey($type)
|
||||
{
|
||||
return 'payment_methods.' . session('company_id') . '.' . $type;
|
||||
return 'payment_methods.' . company_id() . '.' . $type;
|
||||
}
|
||||
|
||||
protected static function sortPaymentMethods(&$list)
|
||||
|
@ -11,7 +11,7 @@ class Overrider
|
||||
public static function load($type)
|
||||
{
|
||||
// Overrides apply per company
|
||||
$company_id = session('company_id');
|
||||
$company_id = company_id();
|
||||
if (empty($company_id)) {
|
||||
return;
|
||||
}
|
||||
@ -25,11 +25,6 @@ class Overrider
|
||||
|
||||
protected static function loadSettings()
|
||||
{
|
||||
// Set the active company settings
|
||||
setting()->setExtraColumns(['company_id' => static::$company_id]);
|
||||
setting()->forgetAll();
|
||||
setting()->load(true);
|
||||
|
||||
// Timezone
|
||||
config(['app.timezone' => setting('localisation.timezone', 'UTC')]);
|
||||
date_default_timezone_set(config('app.timezone'));
|
||||
@ -56,7 +51,7 @@ class Overrider
|
||||
}
|
||||
|
||||
// Set app url dynamically
|
||||
config(['app.url' => route('dashboard')]);
|
||||
config(['app.url' => url('/')]);
|
||||
}
|
||||
|
||||
protected static function loadCurrencies()
|
||||
|
@ -68,7 +68,7 @@ class Widgets
|
||||
|
||||
$model = new Widget();
|
||||
$model->id = 0;
|
||||
$model->company_id = session('company_id');
|
||||
$model->company_id = company_id();
|
||||
$model->dashboard_id = session('dashboard_id');
|
||||
$model->class = $class_name;
|
||||
$model->name = $class->getDefaultName();
|
||||
|
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Common\Company;
|
||||
use App\Traits\DateTime;
|
||||
use App\Utilities\Date;
|
||||
use App\Utilities\Widgets;
|
||||
@ -67,6 +68,53 @@ if (!function_exists('show_widget')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('company')) {
|
||||
/**
|
||||
* Get current/any company model.
|
||||
*
|
||||
* @param int|null $id
|
||||
*
|
||||
* @return Company|null
|
||||
*/
|
||||
function company($id = null)
|
||||
{
|
||||
$company = null;
|
||||
|
||||
if (is_null($id)) {
|
||||
$company = Company::getCurrent();
|
||||
}
|
||||
|
||||
if (is_numeric($id)) {
|
||||
$company = Company::find($id);
|
||||
}
|
||||
|
||||
return $company;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('company_id')) {
|
||||
/**
|
||||
* Get id of current company.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function company_id()
|
||||
{
|
||||
return optional(company())->id;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('should_queue')) {
|
||||
/**
|
||||
* Check if queue is enabled.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function should_queue() {
|
||||
return config('queue.default') != 'sync';
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('cache_prefix')) {
|
||||
/**
|
||||
* Cache system added company_id prefix.
|
||||
@ -74,6 +122,6 @@ if (!function_exists('cache_prefix')) {
|
||||
* @return string
|
||||
*/
|
||||
function cache_prefix() {
|
||||
return session('company_id') . '_';
|
||||
return company_id() . '_';
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user