src/Traits/ApiActionsChilds.php
public function childAssociate($request, $idParent, $idChild, $relation)
    {
        $request->request->merge([
            'url' => $request->request->path()
        ]);
        
        $idParent = $this->getRealId($idParent);
        $idChild = $this->getRealId($idChild);
        
        $resourceChild = $this->repository->attach($idParent, $idChild, $relation, $request->all());
        
        if (! $resourceChild) {
            // return $this->notFound();
        }
        
        return $this->success([
            $resourceChild
        ]);
    }
public function childAssociate($request, $idParent, $idChild, $relation)
    {
        $request->request->merge([
            'url' => $request->request->path()
        ]);
        
        $idParent = $this->getRealId($idParent);
        $idChild = $this->getRealId($idChild);
        
        $resourceChild = $this->repository->attach($idParent, $idChild, $relation, $request->all());
        
        if (! $resourceChild) {
            // return $this->notFound();
        }
        
        return $this->success([
            $resourceChild
        ]);
    }
Associate a new child

@return \Illuminate\Http\Response