1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-11 13:42:49 +01:00
invoiceninja/app/Ninja/Transformers/ActivityTransformer.php
David Bomba 147a1b1a94 Add in additional fields for activities transformer (#1129)
* Expense categories

* add dependencies

* expense categories

* expense categories

* expense categories

* Change expense categories into a resource route

* add expenses, contacts, tasks and is_system to activity transformer
2016-10-29 18:48:58 +11:00

39 lines
1.3 KiB
PHP

<?php namespace App\Ninja\Transformers;
use App\Models\Activity;
/**
* @SWG\Definition(definition="Activity", @SWG\Xml(name="Activity"))
*/
class ActivityTransformer extends EntityTransformer
{
protected $defaultIncludes = [ ];
/**
* @var array
*/
protected $availableIncludes = [ ];
/**
* @param Activity $activity
* @return array
*/
public function transform(Activity $activity)
{
return [
'id' => $activity->key(),
'activity_type_id' => $activity->activity_type_id,
'client_id' => $activity->client ? $activity->client->public_id : null,
'user_id' => $activity->user->public_id + 1,
'invoice_id' => $activity->invoice ? $activity->invoice->public_id : null,
'payment_id' => $activity->payment ? $activity->payment->public_id : null,
'credit_id' => $activity->credit ? $activity->credit->public_id : null,
'updated_at' => $this->getTimestamp($activity->updated_at),
'expense_id' => $activity->expense_id ? $activity->expense->public_id : null,
'is_system' => (bool) $activity->is_system ? $activity->is_system : null,
'contact_id' => $activity->contact_id ? $activity->contact->public_id : null
];
}
}