2020-08-05 04:12:38 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2020-08-05 04:12:38 +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)
|
2020-08-05 04:12:38 +02:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2020-08-05 04:12:38 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Transformers\Shop;
|
|
|
|
|
|
|
|
use App\Models\Company;
|
2020-08-05 04:21:26 +02:00
|
|
|
use App\Transformers\EntityTransformer;
|
2020-08-05 04:12:38 +02:00
|
|
|
use App\Utils\Traits\MakesHash;
|
2020-10-28 11:10:49 +01:00
|
|
|
use stdClass;
|
2020-08-05 04:12:38 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class CompanyShopProfileTransformer.
|
|
|
|
*/
|
|
|
|
class CompanyShopProfileTransformer extends EntityTransformer
|
|
|
|
{
|
|
|
|
use MakesHash;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
2023-08-21 03:29:31 +02:00
|
|
|
protected array $defaultIncludes = [
|
2020-08-05 04:12:38 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
2023-08-21 03:29:31 +02:00
|
|
|
protected array $availableIncludes = [
|
2020-08-05 04:12:38 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Company $company
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function transform(Company $company)
|
|
|
|
{
|
2024-01-14 05:05:00 +01:00
|
|
|
$std = new stdClass();
|
2020-08-05 04:12:38 +02:00
|
|
|
|
|
|
|
return [
|
2020-09-06 11:38:10 +02:00
|
|
|
'company_key' => (string) $company->company_key ?: '',
|
2020-08-05 04:12:38 +02:00
|
|
|
'settings' => $this->trimCompany($company),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
private function trimCompany($company)
|
|
|
|
{
|
2024-01-14 05:05:00 +01:00
|
|
|
$std = new stdClass();
|
2020-08-05 04:27:47 +02:00
|
|
|
|
2020-08-05 04:12:38 +02:00
|
|
|
$trimmed_company_settings = [
|
2020-08-05 04:27:47 +02:00
|
|
|
'custom_fields' => $company->custom_fields ?: $std,
|
2020-08-05 04:12:38 +02:00
|
|
|
'custom_value1' => $company->settings->custom_value1,
|
|
|
|
'custom_value2' => $company->settings->custom_value2,
|
|
|
|
'custom_value3' => $company->settings->custom_value3,
|
|
|
|
'custom_value4' => $company->settings->custom_value4,
|
|
|
|
'name' => $company->settings->name,
|
|
|
|
'company_logo' => $company->settings->company_logo,
|
|
|
|
'website' => $company->settings->website,
|
|
|
|
'address1' => $company->settings->address1,
|
|
|
|
'address2' => $company->settings->address2,
|
|
|
|
'city' => $company->settings->city,
|
|
|
|
'state' => $company->settings->state,
|
|
|
|
'postal_code' => $company->settings->postal_code,
|
|
|
|
'phone' => $company->settings->phone,
|
|
|
|
'email' => $company->settings->email,
|
|
|
|
'country_id' => $company->settings->country_id,
|
|
|
|
'vat_number' => $company->settings->vat_number,
|
2024-06-02 11:29:49 +02:00
|
|
|
'product' => $company->settings->translations->product ?? ctrans('texts.product'),
|
|
|
|
'products' => $company->settings->translations->products ?? ctrans('texts.products'),
|
|
|
|
'client_registration_fields' => $company->client_registration_fields,
|
2020-08-05 04:12:38 +02:00
|
|
|
];
|
|
|
|
|
2024-01-14 05:05:00 +01:00
|
|
|
$new_settings = new stdClass();
|
2020-08-05 04:12:38 +02:00
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
foreach ($trimmed_company_settings as $key => $value) {
|
2020-08-05 04:12:38 +02:00
|
|
|
$new_settings->{$key} = $value;
|
2020-09-06 11:38:10 +02:00
|
|
|
}
|
2020-08-05 04:12:38 +02:00
|
|
|
|
|
|
|
return $new_settings;
|
|
|
|
}
|
|
|
|
}
|