akaunting/database/seeds/SampleData.php

67 lines
1.5 KiB
PHP
Raw Normal View History

2020-01-21 19:23:16 +03:00
<?php
namespace Database\Seeds;
use App\Abstracts\Model;
use App\Models\Banking\Account;
use App\Models\Common\Contact;
use App\Models\Common\Item;
use App\Models\Purchase\Bill;
use App\Models\Sale\Invoice;
2020-01-22 18:46:27 +03:00
use App\Models\Setting\Category;
2020-03-15 20:29:07 +03:00
use App\Models\Setting\Tax;
2020-01-21 19:23:16 +03:00
use Illuminate\Database\Seeder;
class SampleData extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::reguard();
2020-04-20 11:35:20 +03:00
config(['mail.default' => 'array']);
2020-03-02 16:42:50 +03:00
2020-01-22 17:05:51 +03:00
$count = (int) $this->command->option('count');
2020-03-15 20:29:07 +03:00
$small_count = ($count <= 10) ? $count : 10;
2020-01-21 19:23:16 +03:00
2020-03-10 19:09:13 +03:00
$this->command->info('Creating sample data...');
2020-03-15 20:29:07 +03:00
$bar = $this->command->getOutput()->createProgressBar(7);
2020-03-10 19:09:13 +03:00
$bar->setFormat('verbose');
$bar->start();
2020-01-22 17:05:51 +03:00
factory(Contact::class, $count)->create();
2020-03-10 19:09:13 +03:00
$bar->advance();
2020-01-22 18:46:27 +03:00
factory(Category::class, $count)->create();
2020-03-10 19:09:13 +03:00
$bar->advance();
2020-03-15 20:29:07 +03:00
factory(Tax::class, $small_count)->states('enabled')->create();
$bar->advance();
2020-01-22 17:05:51 +03:00
factory(Item::class, $count)->create();
2020-03-10 19:09:13 +03:00
$bar->advance();
2020-03-15 20:29:07 +03:00
factory(Account::class, $small_count)->create();
2020-03-10 19:09:13 +03:00
$bar->advance();
2020-01-22 17:05:51 +03:00
factory(Bill::class, $count)->create();
2020-03-10 19:09:13 +03:00
$bar->advance();
2020-01-22 17:05:51 +03:00
factory(Invoice::class, $count)->create();
2020-03-10 19:09:13 +03:00
$bar->advance();
$bar->finish();
$this->command->info('');
$this->command->info('Sample data created.');
2020-01-21 19:23:16 +03:00
Model::unguard();
}
}