$val) { $this->$key = $val; } } /** * @param Collection $list * @return Collection */ static public function makeList(Collection $list) { $ret = collect(); foreach ($list as $data) { $ret->push(new static($data)); } return $ret; } public function toArray(): array { return json_decode(json_encode($this), true); } }