1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-16 16:13:20 +01:00
invoiceninja/app/Factory/CompanyFactory.php

51 lines
1.3 KiB
PHP
Raw Normal View History

2019-06-17 02:15:42 +02:00
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
2019-06-17 02:15:42 +02:00
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. 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;
use App\DataMapper\CompanySettings;
2021-05-24 06:24:16 +02:00
use App\Libraries\MultiDB;
2019-06-17 02:15:42 +02:00
use App\Models\Company;
2021-05-24 06:24:16 +02:00
use App\Utils\Ninja;
2019-06-17 02:15:42 +02:00
use App\Utils\Traits\MakesHash;
class CompanyFactory
{
use MakesHash;
2019-06-17 02:15:42 +02:00
2019-12-07 12:33:49 +01:00
/**
* @param int $account_id
* @return Company
*/
public function create(int $account_id) :Company
{
2019-06-17 02:15:42 +02:00
$company = new Company;
2019-12-07 12:33:49 +01:00
// $company->name = '';
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');
//$company->custom_fields = (object) ['invoice1' => '1', 'invoice2' => '2', 'client1'=>'3'];
$company->custom_fields = (object) [];
2021-05-24 06:24:16 +02:00
if(Ninja::isHosted())
$company->subdomain = MultiDB::randomSubdomainGenerator();
else
$company->subdomain = '';
$company->enabled_modules = config('ninja.enabled_modules'); //32767;//8191; //4095
2021-03-21 21:21:51 +01:00
$company->default_password_timeout = 1800000;
2019-12-07 12:33:49 +01:00
2019-06-17 02:15:42 +02:00
return $company;
}
2019-12-07 12:33:49 +01:00
}