| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- /**
- * 角色分页返回封装.
- *
- * @author nj
- * @date 2021-01-24 02:26:39
- */
- namespace Modules\ManageApi\Responses;
- use Illuminate\Contracts\Support\Responsable;
- class PermissionRolePagesResponse 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) {
- $strPermissions = $v['permissions'];
- $arrPermissions = [];
- if (!empty($strPermissions)) {
- $arrPermissions = explode(',', $strPermissions);
- }
- $v['permissions'] = $arrPermissions;
- }
- }
- return json_success($result);
- }
- }
|