public function link(RecordInterface $record, array $pivotData = []): self
    {
        $this->loadData(true);
        $this->assertValid($record);
        $this->assertPivot($pivotData);

        //Ensure reference
        $record = $this->matchOne($record) ?? $record;

        if (in_array($record, $this->instances, true)) {
            //Merging pivot data
            $this->pivotData->offsetSet($record, $pivotData + $this->getPivot($record));

            if (!in_array($record, $this->updated, true) && !in_array($record, $this->scheduled, true)) {
                //Indicating that record pivot data has been changed
                $this->updated[] = $record;
            }

            return $this;
        }

        //New association
        $this->instances[] = $record;
        $this->scheduled[] = $record;
        $this->pivotData->offsetSet($record, $pivotData);

        return $this;
    }