'id:json_int', 'Name' => 'name:json_string', 'Color' => 'color:json_string', 'Description' => 'description:json_string', ); /** * @return PresentationCategory[] */ public function categories() { return $this->belongsToMany('models\summit\PresentationCategory','PresentationCategoryGroup_Categories','PresentationCategoryGroupID','PresentationCategoryID')->get(); } /** * @return array */ public function toArray() { $values = parent::toArray(); $color = isset($values['color']) ? $values['color']:''; if(empty($color)) $color = 'f0f0ee'; if (strpos($color,'#') === false) { $color = '#'.$color; } $values['color'] = $color; $categories = array(); foreach($this->categories() as $c) { array_push($categories, intval($c->ID)); } $values['tracks'] = $categories; return $values; } }