setProperties(array( 'type' => $type, 'authorUser' => (!$author->isNull() && !$author->staff) ? $author : null, 'authorStaff' => (!$author->isNull() && $author->staff) ? $author : null, 'to' => $to, )); $log->store(); } public function toArray() { return [ 'type' => $this->type, 'to' => $this->to, 'author' => ($this->authorUser) ? $this->authorUser->toArray() : $this->authorStaff->toArray() ]; } }