<?php

namespace CliqThemes\ORM\Relations;

use CliqThemes\ORM\Model;

/**
 * Base relation implementation shared by concrete relationship types.
 */
abstract class Relation
{
    protected Model $parent;

    protected Model $related;

    /**
     * @param Model $parent  The model owning the relation.
     * @param Model $related Prototype instance of the related model.
     */
    public function __construct(Model $parent, Model $related)
    {
        $this->parent = $parent;
        $this->related = $related;
    }

    /**
     * Execute the relationship query and return the results.
     */
    abstract public function getResults(): mixed;

    /**
     * Create a new query builder instance for the related model.
     */
    protected function newRelatedQuery()
    {
        return $this->related::query();
    }
}

