public function addAttachment($attachment, $group = 'contents')
    {
        if (!$attachment instanceof AttachableInterface && !$attachment instanceof ModelInterface) {
            return false;
        }

        $join = $this->modelFactory()->create(Join::class);

        $objId   = $this->id();
        $objType = $this->objType();
        $attId   = $attachment->id();

        $join->setAttachmentId($attId);
        $join->setObjectId($objId);
        $join->setGroup($group);
        $join->setObjectType($objType);

        $join->save();

        return $this;
    }
public function addAttachment($attachment, $group = 'contents')
    {
        if (!$attachment instanceof AttachableInterface && !$attachment instanceof ModelInterface) {
            return false;
        }

        $join = $this->modelFactory()->create(Join::class);

        $objId   = $this->id();
        $objType = $this->objType();
        $attId   = $attachment->id();

        $join->setAttachmentId($attId);
        $join->setObjectId($objId);
        $join->setGroup($group);
        $join->setObjectType($objType);

        $join->save();

        return $this;
    }
public function addAttachment ( $ attachment , $ group = 'contents' ) { if ( ! $ attachment instanceof AttachableInterface && ! $ attachment instanceof ModelInterface ) { return false ; } $ join = $ this -> modelFactory ( ) -> create ( Join :: class ) ; $ objId = $ this -> id ( ) ; $ objType = $ this -> objType ( ) ; $ attId = $ attachment -> id ( ) ; $ join -> setAttachmentId ( $ attId ) ; $ join -> setObjectId ( $ objId ) ; $ join -> setGroup ( $ group ) ; $ join -> setObjectType ( $ objType ) ; $ join -> save ( ) ; return $ this ; }
Attach an node to the current object.

@param  AttachableInterface|ModelInterface $attachment An attachment or object.
@param  string                             $group      Attachment group, defaults to contents.
@return boolean|self
Attach an node to the current object .