public function toArray() { $array = parent::toArray(); $array['bgUrl'] = $this->getBgUrl(); /** @var User $user */ if ($user = Auth::user()) { $toDoManager = new ToDoManager(); $array['isOnToDoList'] = $toDoManager->userHasTaskToDo($this, $user); $array['hasCompleted'] = $user->hasCompletedTask($this); } $array['cost'] = $this->cost ? round($this->cost) : null; $array['time'] = $this->time ? round($this->time) : null; $array['rating'] = $this->rating ? round($this->rating) : null; return $array; }