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

133
src/Models/Laravel5/Abc.php Normal file
View File

@@ -0,0 +1,133 @@
<?php
namespace XaiCorp\AbcParser\Models\Laravel5;
use XaiCorp\AbcParser\Interfaces\Builder;
use XaiCorp\AbcParser\Interfaces\Exporter;
use XaiCorp\AbcParser\Interfaces\Manipulator;
use XaiCorp\AbcParser\Models\Laravel5\Collection;
class Abc implements Builder, Manipulator, Exporter
{
/**
* @var \XaiCorp\AbcParser\Models\Laravel5\Collection
*/
public $collection;
/**
* @var Tune
*/
public $tune;
/**
* @var TuneSetting
*/
public $setting;
public function __construct()
{
$this->collection = new Collection();
}
public function newCollection()
{
$this->collection = new Collection();
}
public function appendToCollection($key, $data)
{
$allowedKeys = ['A', 'C', 'D', 'H', 'R', 'F', 'B', 'M', 'L', 'N', 'O', 'S', 'Z'];
if (in_array($key, $allowedKeys)) {
$array = $this->collection->$key;
$array[] = $data;
$this->setOnCollection($key, $array);
}
}
public function setOnCollection($key, $data)
{
$allowedKeys = ['A', 'C', 'D', 'H', 'R', 'F', 'B', 'M', 'L', 'N', 'O', 'S', 'Z'];
if (in_array($key, $allowedKeys)) {
$this->collection->$key = $data;
}
}
public function getCollection()
{
return $this->collection;
}
public function newTune()
{
$this->tune = new Tune();
}
public function appendToTune($key, $data)
{
$array = $this->tune->$key;
$array[] = $data;
$this->setOnTune($key, $array);
}
public function setOnTune($key, $data)
{
$this->tune->$key = $data;
}
public function newSetting()
{
$this->setting = new TuneSetting();
}
public function appendToSetting($key, $data)
{
$array = $this->setting->$key;
$array[] = $data;
$this->setOnSetting($key, $array);
}
public function setOnSetting($key, $data)
{
$this->setting->$key = $data;
}
public function newPerson(array $data)
{
$person = new Person();
foreach ($data as $key => $value) {
$person->{$key} = $value;
}
return $person;
}
public function storeTune($music)
{
$this->setting->music = $music;
$this->setting->tune = $this->tune;
$this->collection->appendSetting($this->setting);
}
public function getTunes()
{
$this->collection->getSettings();
}
public function removeTune($tuneIndex)
{}
public function toAbc()
{
$this->toJson();
}
public function toJson()
{
$this->collection->toJson();
}
}

View File

@@ -0,0 +1,75 @@
<?php
namespace XaiCorp\AbcParser\Models\Laravel5;
trait AttributesTrait
{
public function getAttr($type)
{
return $this->$type;
}
public function loadAttr($type)
{
$result = [];
call_user_func([$this->attributesClass, $type.'s'], [$this->id])
->get()
->each(function ($item, $key) use (&$result) {
$result[] = $item->string;
});
if (! empty($result)) {
$this->setAttr($type, $result);
}
return $this;
}
public function setAttr($type, array $values)
{
$this->$type = $values;
}
public function saveAttr($type)
{
$values = $this->$type;
if (! empty($values)) {
$instance = new $this->attributesClass();
foreach ($values as $key => $value) {
$attr = $instance->attr($type, $value, $this)->first();
if (!$attr) {
$attr = new $this->attributesClass();
}
$attr->fill([
'tune_id' => $this->id,
'setting_id' => $this->id,
'collection_id' => $this->id,
'type' => $type,
'string' => $value,
'ordering' => $key,
]);
$attr->save();
}
}
}
public function newFromBuilder($attributes = [], $connection = null)
{
$class = new \ReflectionClass($this->attributesClass);
$model = parent::newFromBuilder($attributes, $connection);
foreach ($class->getStaticPropertyValue('types') as $attribute) {
$model = $model->loadAttr($attribute);
}
return $model;
}
public function save(array $options = [])
{
$class = new \ReflectionClass($this->attributesClass);
foreach ($class->getStaticPropertyValue('types') as $attribute) {
$this->saveAttr($attribute);
}
$saved = parent::save($options);
return $saved;
}
}

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;
}
}

View File

@@ -0,0 +1,190 @@
<?php
namespace XaiCorp\AbcParser\Models\Laravel5;
use XaiCorp\AbcParser\Traits\ValidationTrait;
class CollectionAttribute extends ValidatingModel
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'collection_attributes';
/**
* @var array
*/
protected $validationRules = [
'collection_id' => 'required|integer|exists:collections,id',
'type' => 'required|string|in:Author,Composer,Discography,Rhythm,History,File,Book,Note,Source,Transcriber',
'string' => 'required|string|max:255',
'ordering' => 'required|integer'
];
/**
* supported attribute types
* @var array
*/
public static $types = [
'Author',
'Composer',
'Discography',
'Rhythm',
'History',
'File',
'Book',
'Note',
'Origin',
'Source',
'Transcriber',
];
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['collection_id', 'type', 'string', 'ordering'];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = ['collection_id', 'type', 'ordering'];
public static function getTypes()
{
return self::$types;
}
/*****************************************************************
* Scopes
*/
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $id
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeAuthors($query, $id)
{
return $query->where('type', 'Author')->where('collection_id', $id);
}
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $id
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeComposers($query, $id)
{
return $query->where('type', 'Composer')->where('collection_id', $id);
}
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $id
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeDiscographys($query, $id)
{
return $query->where('type', 'Discography')->where('collection_id', $id);
}
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $id
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeFiles($query, $id)
{
return $query->where('type', 'File')->where('collection_id', $id);
}
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $id
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeRhythms($query, $id)
{
return $query->where('type', 'Rhythm')->where('collection_id', $id);
}
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $id
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeHistorys($query, $id)
{
return $query->where('type', 'History')->where('collection_id', $id);
}
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $id
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeBooks($query, $id)
{
return $query->where('type', 'Book')->where('collection_id', $id);
}
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $id
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeNotes($query, $id)
{
return $query->where('type', 'Note')->where('collection_id', $id);
}
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $id
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeOrigins($query, $id)
{
return $query->where('type', 'Origin')->where('collection_id', $id);
}
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $id
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeSources($query, $id)
{
return $query->where('type', 'Source')->where('collection_id', $id);
}
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $id
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeTranscribers($query, $id)
{
return $query->where('type', 'Transcriber')->where('collection_id', $id);
}
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $attr
* @param mixed $value
* @param \XaiCorp\AbcParser\Models\Laravel5\Tune|null $collection
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeAttr($query, $attr, $value, Collection $collection = null)
{
if ($collection) {
$query = $query->where('collection_id', $collection->id);
}
return $query->where('type', strtolower($attr))->where('string', $value);
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace XaiCorp\AbcParser\Models\Laravel5;
use Illuminate\Database\Eloquent\Model as BaseModel;
use XaiCorp\AbcParser\Traits\ValidationTrait;
class Person extends BaseModel
{
use ValidationTrait;
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'persons';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['name', 'email'];
protected $hidden = ['email'];
//Relationships
public function toArray()
{
return $this->name;
}
}

View File

@@ -0,0 +1,121 @@
<?php
namespace XaiCorp\AbcParser\Models\Laravel5;
use Illuminate\Database\Eloquent\Model as BaseModel;
use XaiCorp\AbcParser\Traits\ValidationTrait;
class Tune extends ValidatingModel
{
use AttributesTrait;
/**
* for AttributesTrait
* @var string
*/
protected $attributesClass = TuneAttribute::class;
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'tunes';
/**
* @var array
*/
protected $validationRules = [
'x_id' => 'integer|min:1',
];
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['x_id', 'X', 'T'];
protected $hidden = ['x_id', 'Title', 'Group', 'Origin', 'Rhythm', 'History'];
protected $appends = ['T', 'G', 'O', 'R', 'H'];
/**************************************************************
* mutators and accessors
*/
protected $Title;
public function getTAttribute()
{
return $this->getAttr('Title');
}
public function setTAttribute(array $values)
{
$this->setAttr('Title', $values);
}
protected $Group;
public function getGAttribute()
{
return $this->getAttr('Group');
}
public function setGAttribute(array $values)
{
$this->setAttr('Group', $values);
}
public function getOAttribute()
{
return $this->getAttr('Origin');
}
protected $Origin;
public function setOAttribute(array $values)
{
$this->setAttr('Origin', $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);
}
public function toArray()
{
$arr = parent::toArray();
foreach (['A','C'] 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;
}
}

View File

@@ -0,0 +1,134 @@
<?php
namespace XaiCorp\AbcParser\Models\Laravel5;
use XaiCorp\AbcParser\Traits\ValidationTrait;
class TuneAttribute extends ValidatingModel
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'tune_attributes';
/**
* @var array
*/
protected $validationRules = [
'tune_id' => 'required|integer|exists:tunes,id',
'type' => 'required|string|in:Title,Group,Origin,Rhythm,History',
'string' => 'required|string|max:255',
'ordering' => 'required|integer'
];
/**
* supported attribute types
* @var array
*/
public static $types = [
'Title',
'Group',
'Origin',
'Rhythm',
'History'
];
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['tune_id', 'type', 'string', 'ordering'];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = ['tune_id', 'type', 'ordering'];
public static function getTypes()
{
return self::$types;
}
/*****************************************************************
* Scopes
*/
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $id
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeTitle($query, $value)
{
return $query->where('type', 'Title')->where('string', $value);
}
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $id
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeTitles($query, $id)
{
return $query->where('type', 'Title')->where('tune_id', $id);
}
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $id
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeGroups($query, $id)
{
return $query->where('type', 'Group')->where('tune_id', $id);
}
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $id
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeOrigins($query, $id)
{
return $query->where('type', 'Origin')->where('tune_id', $id);
}
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $id
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeRhythms($query, $id)
{
return $query->where('type', 'Rhythm')->where('tune_id', $id);
}
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $id
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeHistorys($query, $id)
{
return $query->where('type', 'History')->where('tune_id', $id);
}
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $attr
* @param mixed $value
* @param \XaiCorp\AbcParser\Models\Laravel5\Tune|null $tune
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeAttr($query, $attr, $value, Tune $tune = null)
{
if ($tune) {
$query = $query->where('tune_id', $tune->id);
}
return $query->where('type', strtolower($attr))->where('string', $value);
}
}

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);
}
}

View File

@@ -0,0 +1,145 @@
<?php
namespace XaiCorp\AbcParser\Models\Laravel5;
use XaiCorp\AbcParser\Traits\ValidationTrait;
class TuneSettingAttribute extends ValidatingModel
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'tune_setting_attributes';
/**
* @var array
*/
protected $validationRules = [
'setting_id' => 'required|integer|exists:tune_settings,id',
'type' => 'required|string|in:Transcriber,Note,Discography,Source,Word,Book',
'string' => 'required|string|max:255',
'ordering' => 'required|integer'
];
/**
* supported attribute types
* @var array
*/
public static $types = [
'Transcriber',
'Note',
'Discography',
'Source',
'Word',
'Book'
];
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = ['setting_id', 'type', 'string', 'ordering'];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = ['setting_id', 'type', 'ordering'];
public static function getTypes()
{
return self::$types;
}
/*****************************************************************
* Scopes
*/
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $id
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeTranscriber($query, $value)
{
return $query->where('type', 'Transcriber')->where('string', $value);
}
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $id
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeTranscribers($query, $id)
{
return $query->where('type', 'Transcriber')->where('setting_id', $id);
}
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $id
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeNotes($query, $id)
{
return $query->where('type', 'Note')->where('setting_id', $id);
}
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $id
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeDiscographys($query, $id)
{
return $query->where('type', 'Discography')->where('setting_id', $id);
}
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $id
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeSources($query, $id)
{
return $query->where('type', 'Source')->where('setting_id', $id);
}
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $id
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeWords($query, $id)
{
return $query->where('type', 'Word')->where('setting_id', $id);
}
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param integer $id
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeBooks($query, $id)
{
return $query->where('type', 'Book')->where('setting_id', $id);
}
/**
* @param \Illuminate\Database\Eloquent\Builder $query
* @param string $attr
* @param mixed $value
* @param \XaiCorp\AbcParser\Models\Laravel5\Tune|null $setting
* @return \Illuminate\Database\Eloquent\Builder
*/
public function scopeAttr($query, $attr, $value, TuneSetting $setting = null)
{
if ($setting) {
$query = $query->where('setting_id', $setting->id);
}
return $query->where('type', strtolower($attr))->where('string', $value);
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace XaiCorp\AbcParser\Models\Laravel5;
use Illuminate\Database\Eloquent\Model as BaseModel;
use XaiCorp\AbcParser\Traits\ValidationTrait;
class ValidatingModel extends BaseModel
{
use ValidationTrait;
/**
* validation rules to apply to model attributes
* @var array
*/
protected $validationRules = [];
/**
* @param array $options
* @return bool
*/
public function save(array $options = [])
{
if ($this->validate()) {
return parent::save($options);
}
return false;
}
}