fix code3
This commit is contained in:
@@ -67,8 +67,7 @@ class ExpertManagementController extends Controller
|
|||||||
*/
|
*/
|
||||||
public function show(Expert $expert): JsonResponse
|
public function show(Expert $expert): JsonResponse
|
||||||
{
|
{
|
||||||
return $this->successResponse(
|
return $this->successResponse($expert->load(['roles','permissions'])
|
||||||
new ExpertManagementResource($expert)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Admin\Resources;
|
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @method roles()
|
|
||||||
* @method getAllPermissions()
|
|
||||||
*/
|
|
||||||
class ExpertManagementResource extends JsonResource
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Transform the resource into an array.
|
|
||||||
*
|
|
||||||
* @return array<string, mixed>
|
|
||||||
*/
|
|
||||||
public function toArray(Request $request): array
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'id' => $this->id,
|
|
||||||
'username' => $this->username,
|
|
||||||
'first_name' => $this->first_name,
|
|
||||||
'last_name' => $this->last_name,
|
|
||||||
'national_id' => $this->national_id,
|
|
||||||
'email' => $this->email,
|
|
||||||
'phone_number' => $this->phone_number,
|
|
||||||
'province_name' => $this->province_name,
|
|
||||||
'city_name' => $this->city_name,
|
|
||||||
'roles' => $this->resource->roles
|
|
||||||
->pluck('name')
|
|
||||||
->values(),
|
|
||||||
|
|
||||||
'permissions' => $this->resource->getAllPermissions()
|
|
||||||
->pluck('name')
|
|
||||||
->values(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user