Fixes for caching

This commit is contained in:
David Bomba 2021-05-07 23:29:02 +10:00
parent ab0de39c75
commit 2e6471692a
2 changed files with 19 additions and 20 deletions

View File

@ -53,7 +53,6 @@ class SchedulerCheck implements ShouldQueue
try {
Artisan::call('clear-compiled');
Artisan::call('cache:clear');
Artisan::call('route:clear');
Artisan::call('config:cache');
} catch (\Exception $e) {

View File

@ -71,26 +71,26 @@ class Statics
foreach (config('ninja.cached_tables') as $name => $class) {
if (!Cache::has($name)) {
// 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);
}
}
// // 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);
}