1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace App\Http\Resources;
- use App\Models\AdminUser;
- use App\Models\AdminUserArea;
- use App\Traits\ResourceRolePermissionHelpers;
- use Illuminate\Support\Facades\Storage;
- class AdminUserResource extends JsonResource
- {
- use ResourceRolePermissionHelpers;
- /**
- * Transform the resource into an array.
- *
- * @param \Illuminate\Http\Request $request
- *
- * @return array
- */
- public function toArray($request)
- {
- /** @var AdminUser $model */
- $model = $this->resource;
- $test = AdminUserArea::query()->where('area_id', 99999)->where('admin_id', $model->id)->first();
- return [
- 'id' => $model->id,
- 'account' => $model->account,
- 'name' => $model->name,
- 'phone' => $model->phone,
- 'job_number' => $model->job_number,
- 'pid' => $model->pid,
- 'area_remark' => $model->area_remark,
- 'status' => (bool)$model->status,
- 'is_login_app' => (bool)$model->is_login_app,
- 'avatar' => $model->avatar,
- 'roles' => $this->getRoles(),
- 'areas' => $this->getAreas(),
- 'quanbu' => empty($test) ? false : true,
- 'permissions' => $this->getPermissions(),
- 'created_at' => (string)$model->created_at,
- 'updated_at' => (string)$model->updated_at,
- 'merchant_id' => $model->merchant_id,
- ];
- }
- }
|