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,168 @@
<?php
namespace XaiCorp\AbcParser\Models\Laravel5;
use Illuminate\Database\Eloquent\Model as BaseModel;
use XaiCorp\AbcParser\Traits\ValidationTrait;
class TuneSetting extends ValidatingModel
{
use AttributesTrait;
/**
* for AttributesTrait
* @var string
*/
protected $attributesClass = TuneSettingAttribute::class;
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'tune_settings';
/**
* @var array
*/
protected $validationRules = [
'tune_id' => 'required|integer|min:1|exists:tunes,id',
'meter' => 'string|max:3',
'keysig' => 'string|max:5',
'filename' => 'string|max:255',
'tempo' => 'string|max:10',
'L' => 'string|max:5',
'music' => 'string',
'parts' => 'string|max:255'
];
public static $regex_Q = '/\d\/\d\d?=\d{2,3}/i';
public static $regex_L = '/\d\/\d{1,2}/i';
public static $regex_M = '/((C|C\|)|\d{1,2}\/\d{1,3})/i';
public static $regex_K = '/[a-zA-G]{1,5}/i';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['tune_id', 'meter', 'keysig', 'filename', 'tempo', 'L', 'music', 'parts'];
protected $hidden = ['Transcriber', 'Note', 'Discography', 'Source', 'Word', 'Book'];
protected $appends = ['Z', 'N', 'D', 'S', 'W', 'B'];
/**************************************************************
* mutators and accessors
*/
public function setMusicAttribute($value)
{
$this->attributes['music'] = trim($value);
}
/**
* @var Tune
*/
protected $tune;
public function setTuneAttribute(Tune $tune)
{
$this->tune = $tune;
}
public function getTuneAttribute()
{
return $this->tune;
}
protected $Transcriber;
public function getZAttribute()
{
return $this->getAttr('Transcriber');
}
public function setZAttribute(array $values)
{
$this->setAttr('Transcriber', $values);
}
protected $Note;
public function getNAttribute()
{
return $this->getAttr('Note');
}
public function setNAttribute(array $values)
{
$this->setAttr('Note', $values);
}
protected $Discography;
public function getDAttribute()
{
return $this->getAttr('Discography');
}
public function setDAttribute(array $values)
{
$this->setAttr('Discography', $values);
}
protected $Source;
public function getSAttribute()
{
return $this->getAttr('Source');
}
public function setSAttribute(array $values)
{
$this->setAttr('Source', $values);
}
protected $Word;
public function getWAttribute()
{
return $this->getAttr('Word');
}
public function setWAttribute(array $values)
{
$this->setAttr('Word', $values);
}
protected $Book;
public function getBAttribute()
{
return $this->getAttr('Book');
}
public function setBAttribute(array $values)
{
$this->setAttr('Book', $values);
}
/**
* @return array
*/
public function toArray()
{
$arr = parent::toArray();
if (isset($arr['Z'])) {
foreach ($arr['Z'] as $key => $person) {
$arr['Z'][$key] = $person->name;
}
}
foreach ($arr as $key => $val) {
if (empty($val)) {
unset($arr[$key]);
}
}
$tune = $this->tune->toArray();
return array_merge($this->tune->toArray(), $arr);
}
}