2019-03-28 22:35:35 +01:00
|
|
|
<?php
|
2019-05-11 05:32:07 +02:00
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2023-01-28 23:21:40 +01:00
|
|
|
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-05-11 05:32:07 +02:00
|
|
|
*
|
2021-06-16 08:58:16 +02:00
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
2019-05-11 05:32:07 +02:00
|
|
|
*/
|
2019-03-28 22:35:35 +01:00
|
|
|
|
|
|
|
namespace App\Transformers;
|
|
|
|
|
|
|
|
use App\Models\ClientContact;
|
2019-04-03 02:09:22 +02:00
|
|
|
use App\Utils\Traits\MakesHash;
|
2019-03-28 22:35:35 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class ContactTransformer.
|
|
|
|
*/
|
|
|
|
class ClientContactTransformer extends EntityTransformer
|
|
|
|
{
|
2019-04-03 02:09:22 +02:00
|
|
|
use MakesHash;
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2019-03-28 22:35:35 +01:00
|
|
|
/**
|
|
|
|
* @param ClientContact $contact
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function transform(ClientContact $contact)
|
|
|
|
{
|
|
|
|
return [
|
2019-04-03 02:09:22 +02:00
|
|
|
'id' => $this->encodePrimaryKey($contact->id),
|
2019-03-28 22:35:35 +01:00
|
|
|
'first_name' => $contact->first_name ?: '',
|
|
|
|
'last_name' => $contact->last_name ?: '',
|
|
|
|
'email' => $contact->email ?: '',
|
2020-09-06 11:38:10 +02:00
|
|
|
'created_at' => (int) $contact->created_at,
|
|
|
|
'updated_at' => (int) $contact->updated_at,
|
|
|
|
'archived_at' => (int) $contact->deleted_at,
|
2019-03-28 22:35:35 +01:00
|
|
|
'is_primary' => (bool) $contact->is_primary,
|
2019-07-09 12:32:26 +02:00
|
|
|
'is_locked' => (bool) $contact->is_locked,
|
2019-03-28 22:35:35 +01:00
|
|
|
'phone' => $contact->phone ?: '',
|
|
|
|
'custom_value1' => $contact->custom_value1 ?: '',
|
|
|
|
'custom_value2' => $contact->custom_value2 ?: '',
|
2019-07-09 12:32:26 +02:00
|
|
|
'custom_value3' => $contact->custom_value3 ?: '',
|
|
|
|
'custom_value4' => $contact->custom_value4 ?: '',
|
2020-01-03 09:49:59 +01:00
|
|
|
'contact_key' => $contact->contact_key ?: '',
|
2020-02-26 04:26:07 +01:00
|
|
|
'send_email' => (bool) $contact->send_email,
|
2020-09-06 11:38:10 +02:00
|
|
|
'last_login' => (int) $contact->last_login,
|
2020-03-05 09:36:52 +01:00
|
|
|
'password' => empty($contact->password) ? '' : '**********',
|
2020-09-30 00:42:55 +02:00
|
|
|
'link' => $contact->getLoginLink(),
|
2019-03-28 22:35:35 +01:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|