mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Fixes for randomdataseeder
This commit is contained in:
parent
999ead0fec
commit
6e92666400
@ -47,11 +47,12 @@ use App\Repositories\InvoiceRepository;
|
|||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use App\Events\Payment\PaymentWasCreated;
|
use App\Events\Payment\PaymentWasCreated;
|
||||||
use App\Helpers\Invoice\InvoiceSumInclusive;
|
use App\Helpers\Invoice\InvoiceSumInclusive;
|
||||||
|
use App\Utils\Traits\AppSetup;
|
||||||
|
|
||||||
class RandomDataSeeder extends Seeder
|
class RandomDataSeeder extends Seeder
|
||||||
{
|
{
|
||||||
use \App\Utils\Traits\MakesHash;
|
use \App\Utils\Traits\MakesHash;
|
||||||
|
use AppSetup;
|
||||||
/**
|
/**
|
||||||
* Run the database seeds.
|
* Run the database seeds.
|
||||||
*
|
*
|
||||||
@ -59,30 +60,8 @@ 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) {
|
$this->buildCache(true);
|
||||||
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