setProperties(array( 'type' => $type, 'to' => $to, 'date' => Date::getCurrentDate() )); if($author instanceof User) { $log->authorUser = $author; } else { $log->authorStaff = $author; } $log->store(); } public function toArray() { $author = ($this->authorUser instanceof User) ? $this->authorUser : $this->authorStaff; return [ 'type' => $this->type, 'to' => $this->to, 'author' => [ 'name' => $author->name, 'id' => $author->id, 'staff' => $author instanceof Staff ], 'date' => $this->date ]; } }