2019-09-27 06:31:13 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Transformers;
|
|
|
|
|
|
|
|
use App\Models\Activity;
|
|
|
|
use App\Utils\Traits\MakesHash;
|
|
|
|
|
|
|
|
class ActivityTransformer extends EntityTransformer
|
|
|
|
{
|
|
|
|
use MakesHash;
|
|
|
|
|
|
|
|
protected $defaultIncludes = [];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected $availableIncludes = [];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Activity $activity
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function transform(Activity $activity)
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'id' => (string) $this->encodePrimaryKey($activity->id),
|
|
|
|
'activity_type_id' => (string) $activity->activity_type_id,
|
2019-12-29 23:06:42 +01:00
|
|
|
'client_id' => $activity->client_id ? (string) $this->encodePrimaryKey($activity->client_id) : '',
|
|
|
|
'company_id' => $activity->company_id ? (string) $this->encodePrimaryKey($activity->company_id) : '',
|
2019-11-29 12:15:50 +01:00
|
|
|
'user_id' => (string) $this->encodePrimaryKey($activity->user_id),
|
2019-12-29 23:06:42 +01:00
|
|
|
'invoice_id' => $activity->invoice_id ? (string) $this->encodePrimaryKey($activity->invoice_id) : '',
|
|
|
|
'payment_id' => $activity->payment_id ? (string) $this->encodePrimaryKey($activity->payment_id) : '',
|
|
|
|
'credit_id' => $activity->credit_id ? (string) $this->encodePrimaryKey($activity->credit_id) : '',
|
2020-01-27 11:53:08 +01:00
|
|
|
'updated_at' => (int)$activity->updated_at,
|
2020-02-27 00:32:44 +01:00
|
|
|
'created_at' => (int)$activity->created_at,
|
2019-12-29 23:06:42 +01:00
|
|
|
'expense_id' => $activity->expense_id ? (string) $this->encodePrimaryKey($activity->expense_id) : '',
|
2019-09-27 06:31:13 +02:00
|
|
|
'is_system' => (bool) $activity->is_system,
|
2019-12-29 23:06:42 +01:00
|
|
|
'contact_id' => $activity->contact_id ? (string) $this->encodePrimaryKey($activity->contact_id) : '',
|
|
|
|
'task_id' => $activity->task_id ? (string) $this->encodePrimaryKey($activity->task_id) : '',
|
2019-12-30 22:59:12 +01:00
|
|
|
'notes' => $activity->notes ? (string) $activity->notes : '',
|
|
|
|
'ip' => (string) $activity->ip,
|
2019-09-27 06:31:13 +02:00
|
|
|
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|