mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-14 07:02:34 +01:00
Fixes for statics
This commit is contained in:
parent
2109b8be52
commit
b074338947
@ -12,6 +12,7 @@
|
||||
namespace App\Utils;
|
||||
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
@ -69,6 +70,28 @@ class Statics
|
||||
$data = [];
|
||||
|
||||
foreach (config('ninja.cached_tables') as $name => $class) {
|
||||
|
||||
if (!Cache::has($name)) {
|
||||
|
||||
// check that the table exists in case the migration is pending
|
||||
if (!Schema::hasTable((new $class())->getTable())) {
|
||||
continue;
|
||||
}
|
||||
if ($name == 'payment_terms') {
|
||||
$orderBy = 'num_days';
|
||||
} elseif ($name == 'fonts') {
|
||||
$orderBy = 'sort_order';
|
||||
} elseif (in_array($name, ['currencies', 'industries', 'languages', 'countries', 'banks'])) {
|
||||
$orderBy = 'name';
|
||||
} else {
|
||||
$orderBy = 'id';
|
||||
}
|
||||
$tableData = $class::orderBy($orderBy)->get();
|
||||
if ($tableData->count()) {
|
||||
Cache::forever($name, $tableData);
|
||||
}
|
||||
}
|
||||
|
||||
$data[$name] = Cache::get($name);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user