akaunting/database/seeds/SampleData.php

68 lines
1.7 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;
2020-12-24 01:28:38 +03:00
use App\Models\Document\Document;
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
2022-06-01 10:15:55 +03:00
$company = (int) $this->command->option('company');
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();
2022-06-01 10:15:55 +03:00
Contact::factory()->company($company)->count($count)->create();
2020-03-10 19:09:13 +03:00
$bar->advance();
2022-06-01 10:15:55 +03:00
Category::factory()->company($company)->count($count)->create();
2020-03-10 19:09:13 +03:00
$bar->advance();
2022-06-01 10:15:55 +03:00
Tax::factory()->company($company)->count($small_count)->enabled()->create();
2020-03-15 20:29:07 +03:00
$bar->advance();
2022-06-01 10:15:55 +03:00
Item::factory()->company($company)->count($count)->create();
2020-03-10 19:09:13 +03:00
$bar->advance();
2022-06-01 10:15:55 +03:00
Account::factory()->company($company)->count($small_count)->create();
2020-03-10 19:09:13 +03:00
$bar->advance();
2022-06-01 10:15:55 +03:00
Document::factory()->company($company)->bill()->count($count)->create();
2020-03-10 19:09:13 +03:00
$bar->advance();
2022-06-01 10:15:55 +03:00
Document::factory()->company($company)->invoice()->count($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();
}
}