invoiceninja/app/Transformers/ClientContactTransformer.php

38 lines
1,023 B
PHP
Raw Normal View History

2019-03-29 08:35:35 +11:00
<?php
namespace App\Transformers;
use App\Models\ClientContact;
2019-04-03 11:09:22 +11:00
use App\Utils\Traits\MakesHash;
2019-03-29 08:35:35 +11:00
/**
* Class ContactTransformer.
*
* @SWG\Definition(definition="ClientContact", @SWG\Xml(name="ClientContact"))
*/
class ClientContactTransformer extends EntityTransformer
{
2019-04-03 11:09:22 +11:00
use MakesHash;
2019-03-29 08:35:35 +11:00
/**
* @param ClientContact $contact
*
* @return array
*
*/
public function transform(ClientContact $contact)
{
return [
2019-04-03 11:09:22 +11:00
'id' => $this->encodePrimaryKey($contact->id),
2019-03-29 08:35:35 +11:00
'first_name' => $contact->first_name ?: '',
'last_name' => $contact->last_name ?: '',
'email' => $contact->email ?: '',
'updated_at' => $contact->updated_at,
'archived_at' => $contact->deleted_at,
'is_primary' => (bool) $contact->is_primary,
'phone' => $contact->phone ?: '',
'custom_value1' => $contact->custom_value1 ?: '',
'custom_value2' => $contact->custom_value2 ?: '',
];
}
}