Fixes for seeder and typo in readme (#3109)

* Adjustments for template controller to make entity and entity_id optional

* Fixes for seeder

* Fix for typo
This commit is contained in:
David Bomba 2019-12-01 09:59:51 +11:00 committed by GitHub
parent cbe4dc072b
commit a7f939c6b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 1 deletions

View File

@ -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

View File

@ -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');