settings) { $this->settings = new \Illuminate\Support\Collection(); } $this->settings->push($setting); return $this->settings; } public function getSettings() { return $this->settings; } /************************************************************** * mutators and accessors */ protected $Author; public function getAAttribute() { return $this->getAttr('Author'); } public function setAAttribute(array $values) { $this->setAttr('Author', $values); } protected $Composer; public function getCAttribute() { return $this->getAttr('Composer'); } public function setCAttribute(array $values) { $this->setAttr('Composer', $values); } protected $Discography; public function getDAttribute() { return $this->getAttr('Discography'); } public function setDAttribute(array $values) { $this->setAttr('Discography', $values); } protected $Rhythm; public function getRAttribute() { return $this->getAttr('Rhythm'); } public function setRAttribute(array $values) { $this->setAttr('Rhythm', $values); } protected $History; public function getHAttribute() { return $this->getAttr('History'); } public function setHAttribute(array $values) { $this->setAttr('History', $values); } protected $File; public function getFAttribute() { return $this->getAttr('File'); } public function setFAttribute(array $values) { $this->setAttr('File', $values); } protected $Book; public function getBAttribute() { return $this->getAttr('Book'); } public function setBAttribute(array $values) { $this->setAttr('Book', $values); } protected $Note; public function getNAttribute() { return $this->getAttr('Note'); } public function setNAttribute(array $values) { $this->setAttr('Note', $values); } protected $Origin; public function getOAttribute() { return $this->getAttr('Origin'); } public function setOAttribute(array $values) { $this->setAttr('Origin', $values); } protected $Source; public function getSAttribute() { return $this->getAttr('Source'); } public function setSAttribute(array $values) { $this->setAttr('Source', $values); } protected $Transcriber; public function getZAttribute() { return $this->getAttr('Transcriber'); } public function setZAttribute(array $values) { $this->setAttr('Transcriber', $values); } /** * implementation of Countable::count() * * @return int the number of tunes in the collection */ public function count() { return count($this->settings); } public function toArray() { $arr = parent::toArray(); foreach ($this->settings->toArray() as $key => $setting) { $arr[$key+1] = $setting; } foreach (['A', 'C', 'Z'] as $attr) { if (isset($arr[$attr])) { foreach ($arr[$attr] as $key => $person) { $arr[$attr][$key] = $person->name; } } } foreach ($arr as $key => $val) { if (empty($val)) { unset($arr[$key]); } } return $arr; } }