| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- /**
- * 角色详情.
- *
- * @author nj <nj@gmail.com>
- * @date 2020-01-24 02:23:36
- */
- declare(strict_types=1);
- namespace Modules\Manage\Responses;
- use App\Contracts\Responsable;
- class PermissionRoleDetailResponse 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
- ) {
- if (empty($this->data)) {
- return json_fail(trans('common.err_resource_not_found'));
- }
- $result = $this->data->toArray();
- $strPermissions = $result['permissions'];
- $arrPermissions = [];
- if (!empty($strPermissions)) {
- $arrPermissions = explode(',', $strPermissions);
- }
- $result['permissions'] = $arrPermissions;
- return json_success($result);
- }
- }
|