<?php
namespace Moto\System; use Moto; use Illuminate; use ArrayAccess; use JsonSerializable; class SimpleModel implements ArrayAccess, JsonSerializable { use Illuminate\Database\Eloquent\Concerns\HasAttributes; use Illuminate\Database\Eloquent\Concerns\GuardsAttributes; use Illuminate\Database\Eloquent\Concerns\HasTimestamps; use Illuminate\Database\Eloquent\Concerns\HidesAttributes; const CREATED_AT = 'created_at'; const UPDATED_AT = 'updated_at'; public function __construct(array $attributes = []) { $this->fill($attributes); $this->syncOriginal(); } public function fill(array $attributes) { $totallyGuarded = $this->totallyGuarded(); foreach ($this->fillableFromArray($attributes) as $key => $value) { if ($this->isFillable($key)) { $this->setAttribute($key, $value); } elseif ($totallyGuarded) { throw new Illuminate\Database\Eloquent\MassAssignmentException($key); } } return $this; } public function getIncrementing() { return false; } public function relationLoaded($key) { return false; } public function toArray() { return $this->attributesToArray(); } public function toJson($options = 0) { $json = json_encode($this->jsonSerialize(), $options); if (JSON_ERROR_NONE !== json_last_error()) { throw Illuminate\Database\Eloquent\JsonEncodingException::forModel($this, json_last_error_msg()); } return $json; } public function __get($name) { return $this->getAttribute($name); } public function __set($name, $value) { $this->setAttribute($name, $value); } public function __isset($name) { return array_key_exists($name, $this->attributes); } public function __unset($key) { unset($this->attributes[$key]); } public function jsonSerialize() { return $this->toArray(); } public function offsetExists($offset) { return isset($this->{$offset}); } public function offsetGet($offset) { return $this->getAttribute($offset); } public function offsetSet($offset, $value) { $this->setAttribute($offset, $value); } public function offsetUnset($offset) { unset($this->attributes[$offset]); } } 