SimpleEntity.php 667 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace app\framework\Entity;
  3. use app\framework\Model\SimpleModel;
  4. use Illuminate\Contracts\Support\Arrayable;
  5. use Illuminate\Contracts\Support\Jsonable;
  6. class SimpleEntity implements \JsonSerializable,Arrayable,Jsonable
  7. {
  8. /**
  9. * @var SimpleModel
  10. */
  11. public $model;
  12. public function toArray()
  13. {
  14. return $this->model->attributes;
  15. }
  16. public function toJson($options = 0)
  17. {
  18. return json_encode($this->model->toArray(), $options);
  19. }
  20. public function jsonSerialize()
  21. {
  22. return $this->model->toArray();
  23. }
  24. public function __toString()
  25. {
  26. return $this->toJson();
  27. }
  28. }