2019-06-17 02:15:42 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-06-17 02:15:42 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2024-04-12 06:15:41 +02:00
|
|
|
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-06-17 02:15:42 +02:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2019-06-17 02:15:42 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Factory;
|
|
|
|
|
2023-11-26 08:41:42 +01:00
|
|
|
use App\DataMapper\ClientRegistrationFields;
|
|
|
|
use App\DataMapper\CompanySettings;
|
|
|
|
use App\DataMapper\Tax\TaxModel;
|
2023-11-21 22:53:32 +01:00
|
|
|
use App\Libraries\MultiDB;
|
2023-11-26 08:41:42 +01:00
|
|
|
use App\Models\Company;
|
|
|
|
use App\Utils\Ninja;
|
2019-06-17 02:15:42 +02:00
|
|
|
use App\Utils\Traits\MakesHash;
|
|
|
|
|
|
|
|
class CompanyFactory
|
|
|
|
{
|
2019-12-30 22:59:12 +01:00
|
|
|
use MakesHash;
|
2019-06-17 02:15:42 +02:00
|
|
|
|
2019-12-07 12:33:49 +01:00
|
|
|
/**
|
|
|
|
* @param int $account_id
|
|
|
|
* @return Company
|
|
|
|
*/
|
2024-01-14 05:05:00 +01:00
|
|
|
public function create(int $account_id): Company
|
2019-12-30 22:59:12 +01:00
|
|
|
{
|
2024-01-14 05:05:00 +01:00
|
|
|
$company = new Company();
|
2019-06-17 02:15:42 +02:00
|
|
|
$company->account_id = $account_id;
|
|
|
|
$company->company_key = $this->createHash();
|
2019-09-19 07:50:05 +02:00
|
|
|
$company->settings = CompanySettings::defaults();
|
2019-06-17 02:15:42 +02:00
|
|
|
$company->db = config('database.default');
|
2020-02-10 10:53:02 +01:00
|
|
|
$company->custom_fields = (object) [];
|
2021-09-30 00:14:48 +02:00
|
|
|
$company->client_registration_fields = ClientRegistrationFields::generate();
|
2022-06-21 11:57:17 +02:00
|
|
|
|
|
|
|
if (Ninja::isHosted()) {
|
2021-05-24 06:24:16 +02:00
|
|
|
$company->subdomain = MultiDB::randomSubdomainGenerator();
|
2022-06-21 11:57:17 +02:00
|
|
|
} else {
|
2021-05-24 06:24:16 +02:00
|
|
|
$company->subdomain = '';
|
2022-06-21 11:57:17 +02:00
|
|
|
}
|
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
$company->enabled_modules = config('ninja.enabled_modules'); //32767;//8191; //4095
|
2021-03-21 21:21:51 +01:00
|
|
|
$company->default_password_timeout = 1800000;
|
2022-09-05 09:18:08 +02:00
|
|
|
$company->markdown_email_enabled = true;
|
2022-07-22 10:37:27 +02:00
|
|
|
$company->markdown_enabled = false;
|
2023-04-28 08:42:15 +02:00
|
|
|
$company->tax_data = new TaxModel();
|
2024-06-15 09:34:08 +02:00
|
|
|
$company->first_month_of_year = '1';
|
2024-02-16 20:04:38 +01:00
|
|
|
$company->smtp_encryption = 'tls';
|
|
|
|
$company->smtp_host = '';
|
|
|
|
$company->smtp_local_domain = '';
|
|
|
|
$company->smtp_password = '';
|
2024-10-10 00:07:26 +02:00
|
|
|
$company->smtp_port = 0;
|
2024-02-16 20:04:38 +01:00
|
|
|
$company->smtp_username = '';
|
|
|
|
$company->smtp_verify_peer = true;
|
2024-06-14 09:09:44 +02:00
|
|
|
|
2019-06-17 02:15:42 +02:00
|
|
|
return $company;
|
|
|
|
}
|
2019-12-07 12:33:49 +01:00
|
|
|
}
|