12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- namespace App\Http\Resources;
- use App\Models\VueRouter;
- use App\Traits\ModelTree;
- use App\Traits\ResourceRolePermissionHelpers;
- class VueRouterResource extends JsonResource
- {
- use ResourceRolePermissionHelpers;
- use ModelTree;
- public function toArray($request)
- {
- /** @var VueRouter $model */
- $model = $this->resource;
- return [
- 'id' => $model->id,
- 'parent_id' => $model->parent_id,
- 'title' => $model->title,
- 'icon' => $model->icon,
- 'path' => $model->path,
- 'order' => $model->order,
- 'cache' => $model->cache,
- 'menu' => $model->menu,
- 'roles' => $this->when(
- $this->onlyRolePermissionIds,
- $model->roles()->pluck('id'),
- AdminRoleResource::collection($this->whenLoaded('roles'))
- ),
- 'permission' => $model->permission,
- 'created_at' => (string) $model->created_at,
- 'updated_at' => (string) $model->updated_at,
- ];
- }
- }
|