Merge activity transformer

This commit is contained in:
Hillel Coren 2018-09-28 09:40:08 +03:00
parent 862bd4d163
commit e82c259cfa

View File

@ -9,6 +9,21 @@ use App\Models\Activity;
*/ */
class ActivityTransformer extends EntityTransformer class ActivityTransformer extends EntityTransformer
{ {
/**
* @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)
*/
protected $defaultIncludes = []; protected $defaultIncludes = [];
/** /**
@ -25,20 +40,21 @@ class ActivityTransformer extends EntityTransformer
{ {
return [ return [
'id' => $activity->key(), 'id' => $activity->key(),
'activity_type_id' => $activity->activity_type_id, 'activity_type_id' => (int) $activity->activity_type_id,
'client_id' => $activity->client ? $activity->client->public_id : null, 'client_id' => $activity->client ? (int) $activity->client->public_id : null,
'user_id' => $activity->user->public_id + 1, 'user_id' => (int) $activity->user->public_id + 1,
'invoice_id' => $activity->invoice ? $activity->invoice->public_id : null, 'invoice_id' => $activity->invoice ? (int) $activity->invoice->public_id : null,
'payment_id' => $activity->payment ? $activity->payment->public_id : null, 'payment_id' => $activity->payment ? (int) $activity->payment->public_id : null,
'credit_id' => $activity->credit ? $activity->credit->public_id : null, 'credit_id' => $activity->credit ? (int) $activity->credit->public_id : null,
'updated_at' => $this->getTimestamp($activity->updated_at), 'updated_at' => $this->getTimestamp($activity->updated_at),
'expense_id' => $activity->expense_id ? $activity->expense->public_id : null, 'expense_id' => $activity->expense_id ? (int) $activity->expense->public_id : null,
'is_system' => $activity->is_system ? (bool) $activity->is_system : null, 'is_system' => $activity->is_system ? (bool) $activity->is_system : null,
'contact_id' => $activity->contact_id ? (int) $activity->contact->public_id : null, 'contact_id' => $activity->contact_id ? (int) $activity->contact->public_id : null,
'task_id' => $activity->task_id ? (int) $activity->task->public_id : null, 'task_id' => $activity->task_id ? (int) $activity->task->public_id : null,
'notes' => $activity->notes ?: '', 'notes' => $activity->notes ?: '',
'adjustment' => (float) $activity->adjustment, 'adjustment' => (float) $activity->adjustment,
'balance' => (float) $activity->balance, 'balance' => (float) $activity->balance,
]; ];
} }
} }