| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- /**
- * 管理员分页返回封装.
- *
- * @author nj
- * @date 2021-01-23 16:19:51
- */
- namespace Modules\ManageApi\Responses;
- use Illuminate\Contracts\Support\Responsable;
- class VideoPagesResponse implements Responsable
- {
- /**
- * 录入的数据.
- *
- * @var mixed
- */
- private $data = null;
- /**
- * 附加条件参数.
- *
- * @var array
- */
- private $params = [];
- public function __construct($data = null, $params = [])
- {
- $this->data = $data;
- $this->params = $params;
- }
- public function toResponse(
- $request = null
- ) {
- $result = $this->data->toArray();
- if (!empty($result['data'])) {
- foreach ($result['data'] as &$v) {
- if (!empty($v['tags'])) {
- $v['tags'] = explode(',', $v['tags']); //单独处理为数组.
- } else {
- $v['tags'] = [];
- }
- if (!empty($v['screenshots'])) {
- $v['screenshots'] = explode(',', $v['screenshots']); //单独处理为数组.
- } else {
- $v['screenshots'] = [];
- }
- unset($v['id']);
- }
- unset($v['id']);
- }
- return json_success($result);
- }
- }
|