1234567891011121314151617181920212223242526272829 |
- <?php
- namespace App\Http\Resources;
- use App\Models\AdminRole;
- use App\Models\VueRouter;
- use App\Traits\ModelTree;
- use Illuminate\Support\Facades\Log;
- class AdminRoleResource extends JsonResource
- {
- use ModelTree;
- public function toArray($request)
- {
- /** @var AdminRole $model */
- $model = $this->resource;
- return [
- 'id' => $model->id,
- 'name' => $model->name,
- 'slug' => $model->slug,
- 'permissions' => AdminPermissionResource::collection($this->whenLoaded('permissions')),
- 'vue_routers' => VueRouterResource::collection($this->whenLoaded('vue_routers')),
- 'created_at' => (string) $model->created_at,
- 'updated_at' => (string) $model->updated_at,
- ];
- }
- }
|