initial commit

This commit is contained in:
2016-04-15 21:38:56 -04:00
commit 1d3e8e3117
79 changed files with 16223 additions and 0 deletions

View File

@@ -0,0 +1,228 @@
<?php
namespace XaiCorp\AbcParser\Models\Laravel5;
class Collection extends ValidatingModel implements \Countable
{
use AttributesTrait;
/**
* for AttributesTrait
* @var string
*/
protected $attributesClass = CollectionAttribute::class;
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'collections';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['name'];
protected $hidden = [
'Author',
'Composer',
'Discography',
'Rhythm',
'History',
'File',
'Book',
'Note',
'Origin',
'Source',
'Transcriber',
];
protected $appends = ['A','C','D','H','R','F','B','N', 'O','S','Z',];
/**
* @var \Illuminate\Support\Collection
*/
protected $settings;
public function appendSetting($setting)
{
if (! $this->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;
}
}