attributes = $attributes; } /** * @param $key * @param null $default * * @return mixed */ public function get($key, $default = null) { return Arr::get($this->attributes, $key, $default); } /** * @param $key * @param $val * * @return $this */ public function set($key, $val) { $new = $this->attributes; Arr::set($new, $key, $val); return new static($new); } /** * @param $key * * @return $this */ public function delete($key) { $new = $this->attributes; Arr::forget($new, $key); return new static($new); } /** * @param $name * * @return mixed */ public function __get($name) { return $this->get(str_replace('_', '-', $name)); } public function toArray() { return $this->attributes; } public function toJson() { return json_encode($this->toArray()); } }