invoiceninja/app/Ninja/Transformers/ContactTransformer.php

33 lines
901 B
PHP
Raw Normal View History

2017-01-30 21:40:43 +02:00
<?php
namespace App\Ninja\Transformers;
2015-11-03 16:21:17 +02:00
use App\Models\Contact;
/**
2017-01-30 21:40:43 +02:00
* Class ContactTransformer.
*/
2015-11-08 23:12:50 +02:00
class ContactTransformer extends EntityTransformer
2015-11-03 16:21:17 +02:00
{
/**
* @param Contact $contact
2017-01-30 21:40:43 +02:00
*
* @return array
*/
2015-11-03 16:21:17 +02:00
public function transform(Contact $contact)
{
2016-05-03 23:02:29 +03:00
return array_merge($this->getDefaults($contact), [
2015-11-15 21:43:32 +11:00
'id' => (int) $contact->public_id,
2015-11-03 16:21:17 +02:00
'first_name' => $contact->first_name,
'last_name' => $contact->last_name,
'email' => $contact->email,
2015-12-27 13:08:58 +02:00
'updated_at' => $this->getTimestamp($contact->updated_at),
'archived_at' => $this->getTimestamp($contact->deleted_at),
2015-11-07 23:15:37 +11:00
'is_primary' => (bool) $contact->is_primary,
'phone' => $contact->phone,
'last_login' => $contact->last_login,
'send_invoice' => (bool) $contact->send_invoice,
2016-05-03 23:02:29 +03:00
]);
2015-11-03 16:21:17 +02:00
}
2016-10-27 11:57:51 +03:00
}