public function detach(RecordInterface $record): RecordInterface
    {
        $this->loadData(true);
        foreach ($this->instances as $index => $instance) {
            if ($this->match($instance, $record)) {
                //Remove from save
                unset($this->instances[$index]);

                return $instance;
            }
        }

        throw new RelationException("Record {$record} not found in HasMany relation");
    }