mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-03 00:24:33 -04:00
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:
parent
cbe4dc072b
commit
a7f939c6b9
@ -12,7 +12,7 @@ We will be using the lessons learnt in Invoice Ninja 4.0 to build a bigger bette
|
|||||||
|
|
||||||
## Quick Start
|
## 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
|
```bash
|
||||||
git clone https://github.com/invoiceninja/invoiceninja.git
|
git clone https://github.com/invoiceninja/invoiceninja.git
|
||||||
|
@ -25,6 +25,8 @@ use App\Models\User;
|
|||||||
use App\Models\UserAccount;
|
use App\Models\UserAccount;
|
||||||
use App\Repositories\InvoiceRepository;
|
use App\Repositories\InvoiceRepository;
|
||||||
use Illuminate\Database\Seeder;
|
use Illuminate\Database\Seeder;
|
||||||
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
class RandomDataSeeder extends Seeder
|
class RandomDataSeeder extends Seeder
|
||||||
{
|
{
|
||||||
@ -37,6 +39,31 @@ class RandomDataSeeder extends Seeder
|
|||||||
public function run()
|
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');
|
$this->command->info('Running RandomDataSeeder');
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user