akaunting/database/seeds/TestCompany.php

89 lines
2.1 KiB
PHP
Raw Normal View History

2017-09-14 22:21:00 +03:00
<?php
namespace Database\Seeds;
2019-11-16 10:21:14 +03:00
use App\Abstracts\Model;
2019-11-18 10:54:26 +03:00
use App\Jobs\Auth\CreateUser;
2019-12-22 18:57:04 +03:00
use App\Jobs\Common\CreateCompany;
2020-01-07 15:41:47 +03:00
use App\Jobs\Common\CreateContact;
2019-11-18 10:54:26 +03:00
use App\Traits\Jobs;
2017-09-14 22:21:00 +03:00
use Illuminate\Database\Seeder;
class TestCompany extends Seeder
{
2019-11-18 10:54:26 +03:00
use Jobs;
2017-09-14 22:21:00 +03:00
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Model::unguard();
$this->call(Roles::class);
$this->createCompany();
$this->createUser();
2020-01-07 15:41:47 +03:00
$this->createContact();
2017-09-14 22:21:00 +03:00
Model::reguard();
}
private function createCompany()
{
$company = $this->dispatch(new CreateCompany([
2019-12-22 18:57:04 +03:00
'name' => 'My Company',
'domain' => 'company.com',
'address' => 'New Street 1254',
'currency' => 'USD',
'locale' => 'en-GB',
'enabled' => '1',
'settings' => [
2019-12-22 19:15:58 +03:00
'schedule.send_invoice_reminder' => '1',
'schedule.send_bill_reminder' => '1',
2019-12-22 19:27:10 +03:00
'wizard.completed' => '1',
2019-12-22 18:57:04 +03:00
],
]));
2017-09-14 22:21:00 +03:00
session(['company_id' => $company->id]);
2017-09-14 22:21:00 +03:00
$this->command->info('Test company created.');
}
public function createUser()
{
$this->dispatch(new CreateUser([
2019-12-22 18:57:04 +03:00
'name' => 'Test User',
2019-11-18 10:54:26 +03:00
'email' => 'test@company.com',
2017-09-14 22:21:00 +03:00
'password' => '123456',
2019-11-18 10:54:26 +03:00
'locale' => 'en-GB',
'companies' => [session('company_id')],
2019-11-18 10:54:26 +03:00
'roles' => ['1'],
'enabled' => '1',
]));
2019-11-17 15:06:00 +03:00
2019-11-18 10:54:26 +03:00
$this->command->info('Test user created.');
2017-09-14 22:21:00 +03:00
}
2020-01-07 15:41:47 +03:00
private function createContact()
{
$this->dispatch(new CreateContact([
'type' => 'customer',
'name' => 'Test Contact',
'email' => 'contact@company.com',
'currency_code' => setting('default.currency', 'USD'),
'password' => '123456',
'password_confirmation' => '123456',
'company_id' => session('company_id'),
'enabled' => '1',
'create_user' => 1,
]));
$this->command->info('Test contact created.');
}
2017-09-14 22:21:00 +03:00
}