diff --git a/README.md b/README.md index 0b534db8bf27..66c0890fd6fa 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ We will be using the lessons learnt in Invoice Ninja 4.0 to build a bigger bette ## Quick Start -Curently the client portal and API are of alpha quality, to get started: +Currently the client portal and API are of alpha quality, to get started: ```bash git clone https://github.com/invoiceninja/invoiceninja.git diff --git a/database/seeds/RandomDataSeeder.php b/database/seeds/RandomDataSeeder.php index 0597cfc3be06..8bfc090ad70b 100644 --- a/database/seeds/RandomDataSeeder.php +++ b/database/seeds/RandomDataSeeder.php @@ -25,6 +25,8 @@ use App\Models\User; use App\Models\UserAccount; use App\Repositories\InvoiceRepository; use Illuminate\Database\Seeder; +use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Facades\Schema; class RandomDataSeeder extends Seeder { @@ -37,6 +39,31 @@ class RandomDataSeeder extends Seeder public function run() { + /* Warm up the cache !*/ + $cached_tables = config('ninja.cached_tables'); + + foreach ($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); + } + } + } + $this->command->info('Running RandomDataSeeder');