1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-19 16:01:34 +02:00
invoiceninja/app/Ninja/Transformers/ActivityTransformer.php

61 lines
2.4 KiB
PHP
Raw Permalink Normal View History

2017-01-30 20:40:43 +01:00
<?php
namespace App\Ninja\Transformers;
2016-08-15 15:43:26 +02:00
use App\Models\Activity;
/**
* @SWG\Definition(definition="Activity", @SWG\Xml(name="Activity"))
*/
class ActivityTransformer extends EntityTransformer
{
2018-09-28 08:40:08 +02:00
/**
* @SWG\Property(property="id", type="integer", example=1)
* @SWG\Property(property="activity_type_id", type="integer", example=1)
* @SWG\Property(property="client_id", type="integer", example=1)
* @SWG\Property(property="user_id", type="integer", example=1)
* @SWG\Property(property="invoice_id", type="integer", example=1)
* @SWG\Property(property="payment_id", type="integer", example=1)
* @SWG\Property(property="credit_id", type="integer", example=1)
* @SWG\Property(property="updated_at", type="integer", example=1451160233, readOnly=true)
* @SWG\Property(property="expense_id", type="integer", example=1)
* @SWG\Property(property="is_system", type="boolean", example=false)
* @SWG\Property(property="contact_id", type="integer", example=1)
* @SWG\Property(property="task_id", type="integer", example=1)
*/
2017-01-30 20:40:43 +01:00
protected $defaultIncludes = [];
2016-08-15 15:43:26 +02:00
/**
* @var array
*/
2017-01-30 20:40:43 +01:00
protected $availableIncludes = [];
2016-08-15 15:43:26 +02:00
/**
* @param Activity $activity
2017-01-30 20:40:43 +01:00
*
2016-08-15 15:43:26 +02:00
* @return array
*/
public function transform(Activity $activity)
{
return [
2016-08-17 09:55:50 +02:00
'id' => $activity->key(),
2018-09-28 08:40:08 +02:00
'activity_type_id' => (int) $activity->activity_type_id,
'client_id' => $activity->client ? (int) $activity->client->public_id : null,
'user_id' => (int) $activity->user->public_id + 1,
'invoice_id' => $activity->invoice ? (int) $activity->invoice->public_id : null,
'payment_id' => $activity->payment ? (int) $activity->payment->public_id : null,
'credit_id' => $activity->credit ? (int) $activity->credit->public_id : null,
'updated_at' => $this->getTimestamp($activity->updated_at),
2018-09-28 08:40:08 +02:00
'expense_id' => $activity->expense_id ? (int) $activity->expense->public_id : null,
2016-12-18 04:17:20 +01:00
'is_system' => $activity->is_system ? (bool) $activity->is_system : null,
2018-08-02 21:35:59 +02:00
'contact_id' => $activity->contact_id ? (int) $activity->contact->public_id : null,
'task_id' => $activity->task_id ? (int) $activity->task->public_id : null,
2018-09-04 20:22:26 +02:00
'notes' => $activity->notes ?: '',
2018-08-02 21:35:59 +02:00
'adjustment' => (float) $activity->adjustment,
'balance' => (float) $activity->balance,
2018-09-28 08:40:08 +02:00
2016-08-15 15:43:26 +02:00
];
}
}