Handle null invoice object in task (#1153)

This commit is contained in:
David Bomba 2016-11-14 21:25:16 +11:00 committed by GitHub
parent fa39434ac9
commit b7a5ae6059

View File

@ -38,13 +38,18 @@ class TaskTransformer extends EntityTransformer
public function transform(Task $task)
{
if($task->invoice)
$invoiceId = $task->invoice->public_id;
else
$invoiceId = null;
return array_merge($this->getDefaults($task), [
'id' => (int) $task->public_id,
'description' => $task->description,
'duration' => $task->getDuration(),
'updated_at' => (int) $this->getTimestamp($task->updated_at),
'archived_at' => (int) $this->getTimestamp($task->deleted_at),
'invoice_id' => (int) $task->invoice->public_id,
'invoice_id' => $invoiceId,
'client_id' => (int) $task->client->public_id,
'is_deleted' => (bool) $task->is_deleted,
'time_log' => $task->time_log,