2019-01-27 23:13:12 +01:00
|
|
|
<?php
|
2019-05-11 05:32:07 +02:00
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2019. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
2019-01-27 23:13:12 +01:00
|
|
|
|
|
|
|
namespace App\Factory;
|
|
|
|
|
2019-02-17 11:34:46 +01:00
|
|
|
use App\DataMapper\ClientSettings;
|
2019-01-27 23:13:12 +01:00
|
|
|
use App\Models\Client;
|
|
|
|
|
|
|
|
class ClientFactory
|
|
|
|
{
|
|
|
|
public static function create(int $company_id, int $user_id) :Client
|
|
|
|
{
|
|
|
|
$client = new Client;
|
|
|
|
$client->company_id = $company_id;
|
|
|
|
$client->user_id = $user_id;
|
|
|
|
$client->name = '';
|
|
|
|
$client->website = '';
|
|
|
|
$client->private_notes = '';
|
|
|
|
$client->balance = 0;
|
|
|
|
$client->paid_to_date = 0;
|
|
|
|
$client->country_id = 4;
|
|
|
|
$client->is_deleted = 0;
|
2019-08-07 08:56:19 +02:00
|
|
|
$client->client_hash = str_random(40);
|
|
|
|
|
2019-04-24 12:01:40 +02:00
|
|
|
$client->settings = new ClientSettings(ClientSettings::defaults());
|
2019-02-17 11:34:46 +01:00
|
|
|
|
2019-01-27 23:13:12 +01:00
|
|
|
$client_contact = ClientContactFactory::create($company_id, $user_id);
|
|
|
|
$client->contacts->add($client_contact);
|
|
|
|
|
|
|
|
return $client;
|
|
|
|
}
|
|
|
|
}
|