Untitled

 avatar
unknown
plain_text
2 years ago
522 B
7
Indexable
public function show(User $employee)
{
    // second level validation
    if (!$this->user->canViewEmployee($employee)) {
        return response()->json([
            'message' => "Sorry, you are not allowed to do this type of operation.",
        ], 401);
    }

    // get employee roles
    $roles = $employee->getRoleNames();
    $employee->user_roles = $roles;

    // get employee clients
    $employee->clients = $employee->clients()->get()->pluck('id');

    return response()->json($employee);
}
Editor is loading...