2017-01-30 20:40:43 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Ninja\Import\Harvest;
|
2015-12-07 22:41:48 +01:00
|
|
|
|
2015-12-08 11:10:20 +01:00
|
|
|
use App\Ninja\Import\BaseTransformer;
|
2015-12-07 22:41:48 +01:00
|
|
|
use League\Fractal\Resource\Item;
|
|
|
|
|
2016-07-03 18:11:58 +02:00
|
|
|
/**
|
2017-01-30 20:40:43 +01:00
|
|
|
* Class ContactTransformer.
|
2016-07-03 18:11:58 +02:00
|
|
|
*/
|
2015-12-08 11:10:20 +01:00
|
|
|
class ContactTransformer extends BaseTransformer
|
2015-12-07 22:41:48 +01:00
|
|
|
{
|
2016-07-03 18:11:58 +02:00
|
|
|
/**
|
|
|
|
* @param $data
|
2017-01-30 20:40:43 +01:00
|
|
|
*
|
2016-07-03 18:11:58 +02:00
|
|
|
* @return bool|Item
|
|
|
|
*/
|
2015-12-08 11:10:20 +01:00
|
|
|
public function transform($data)
|
2015-12-07 22:41:48 +01:00
|
|
|
{
|
2017-01-30 17:05:31 +01:00
|
|
|
if (! $this->hasClient($data->client)) {
|
2015-12-07 22:41:48 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-12-08 11:10:20 +01:00
|
|
|
return new Item($data, function ($data) {
|
2015-12-07 22:41:48 +01:00
|
|
|
return [
|
2015-12-08 11:10:20 +01:00
|
|
|
'client_id' => $this->getClientId($data->client),
|
2016-01-06 08:52:26 +01:00
|
|
|
'first_name' => $this->getString($data, 'first_name'),
|
|
|
|
'last_name' => $this->getString($data, 'last_name'),
|
|
|
|
'email' => $this->getString($data, 'email'),
|
|
|
|
'phone' => $this->getString($data, 'office_phone') ?: $this->getString($data, 'mobile_phone'),
|
2015-12-07 22:41:48 +01:00
|
|
|
];
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|