source/Spiral/ORM/Entities/Relations/ManyToManyRelation.php
public function unlink(RecordInterface $record): self
    {
        $this->loadData(true);

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

        foreach ($this->instances as $index => $linked) {
            if ($this->match($linked, $record)) {
                //Removing locally
                unset($this->instances[$index]);

                if (!in_array($linked, $this->scheduled, true) || !$this->autoload) {
                    //Scheduling unlink in db when we know relation OR partial mode is on
                    $this->unlinked[] = $linked;
                }
                break;
            }
        }

        $this->instances = array_values($this->instances);

        return $this;
    }
public function unlink(RecordInterface $record): self
    {
        $this->loadData(true);

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

        foreach ($this->instances as $index => $linked) {
            if ($this->match($linked, $record)) {
                //Removing locally
                unset($this->instances[$index]);

                if (!in_array($linked, $this->scheduled, true) || !$this->autoload) {
                    //Scheduling unlink in db when we know relation OR partial mode is on
                    $this->unlinked[] = $linked;
                }
                break;
            }
        }

        $this->instances = array_values($this->instances);

        return $this;
    }
public function unlink ( RecordInterface $ record ) : self { $ this -> loadData ( true ) ; //Ensure reference $ record = $ this -> matchOne ( $ record ) ?? $ record ; foreach ( $ this -> instances as $ index => $ linked ) { if ( $ this -> match ( $ linked , $ record ) ) { //Removing locally unset ( $ this -> instances [ $ index ] ) ; if ( ! in_array ( $ linked , $ this -> scheduled , true ) || ! $ this -> autoload ) { //Scheduling unlink in db when we know relation OR partial mode is on $ this -> unlinked [ ] = $ linked ; } break ; } } $ this -> instances = array_values ( $ this -> instances ) ; return $ this ; }
Unlink specific entity from relation. Will load relation data! Record to delete will be
automatically matched to a give record.

@param RecordInterface $record

@return self

@throws RelationException When entity not linked.
Unlink specific entity from relation . Will load relation data! Record to delete will be automatically matched to a give record .