invoiceninja/app/Ninja/Transformers/VendorContactTransformer.php

34 lines
1.4 KiB
PHP
Raw Permalink Normal View History

2017-01-30 21:40:43 +02:00
<?php
namespace App\Ninja\Transformers;
2016-01-06 20:52:09 +01:00
use App\Models\VendorContact;
2016-01-07 16:21:13 +01:00
// vendor
2016-01-06 20:52:09 +01:00
class VendorContactTransformer extends EntityTransformer
{
2019-01-30 22:00:26 +11:00
/**
* @SWG\Property(property="id", type="integer", example=1, readOnly=true)
* @SWG\Property(property="first_name", type="string", example="Luke")
* @SWG\Property(property="last_name", type="string", example="Smith")
* @SWG\Property(property="email", type="string", example="john.doe@company.com")
* @SWG\Property(property="updated_at", type="integer", example=1451160233, readOnly=true)
* @SWG\Property(property="archived_at", type="integer", example=1451160233, readOnly=true)
* @SWG\Property(property="is_primary", type="boolean", example=false)
* @SWG\Property(property="phone", type="string", example="(212) 555-1212")
*/
2016-01-06 20:52:09 +01:00
public function transform(VendorContact $contact)
{
2016-05-03 23:02:29 +03:00
return array_merge($this->getDefaults($contact), [
2016-01-06 20:52:09 +01:00
'id' => (int) $contact->public_id,
2018-06-26 17:18:32 +05:30
'first_name' => $contact->first_name ?: '',
'last_name' => $contact->last_name ?: '',
'email' => $contact->email ?: '',
2016-01-06 20:52:09 +01:00
'updated_at' => $this->getTimestamp($contact->updated_at),
'archived_at' => $this->getTimestamp($contact->deleted_at),
'is_primary' => (bool) $contact->is_primary,
2018-06-26 17:18:32 +05:30
'phone' => $contact->phone ?: '',
2016-05-03 23:02:29 +03:00
]);
2016-01-06 20:52:09 +01:00
}
2017-01-30 18:05:31 +02:00
}