data = $data; } // Set how the item should be presented ("counters" or "table") public function showAs($showAs) { $this->showAs = $showAs; return $this; } // Set data title (shown as table title in the official app) public function title($title) { $this->title = $title; return $this; } // Set a map of human-readable labels for the data contents public function labels($labels) { $this->labels = $labels; return $this; } // Transform contents to a serializable array with metadata public function toArray() { return array_merge($this->data, [ '__meta' => array_filter([ 'showAs' => $this->showAs, 'title' => $this->title, 'labels' => $this->labels ]) ]); } }