NotIncrementIdDetailResponse.php 905 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. * 管理员分页返回封装.
  4. *
  5. * @author nj
  6. * @date 2021-01-23 16:19:51
  7. */
  8. namespace Modules\ManageApi\Responses;
  9. use Illuminate\Contracts\Support\Arrayable;
  10. use Illuminate\Contracts\Support\Responsable;
  11. class NotIncrementIdDetailResponse implements Responsable
  12. {
  13. /**
  14. * 录入的数据.
  15. *
  16. * @var mixed
  17. */
  18. private $data = null;
  19. /**
  20. * 附加条件参数.
  21. *
  22. * @var array
  23. */
  24. private $params = [];
  25. public function __construct($data = null, $params = [])
  26. {
  27. $this->data = $data;
  28. $this->params = $params;
  29. }
  30. public function toResponse(
  31. $request = null
  32. ) {
  33. if ($this->data instanceof Arrayable) {
  34. $result = $this->data->toArray();
  35. } else {
  36. $result = $this->data;
  37. }
  38. unset($result['id']);
  39. return json_success($result);
  40. }
  41. }