<?php
/**
 * RadiusBooking API Route Registrar
 *
 * This class is responsible for registering API routes dynamically with the WordPress REST API.
 * It supports CRUD operations and allows for middleware to be applied globally or per route.
 *
 * @package RadiusTheme\RadiusBooking\Core\Api\Routes
 */

namespace RadiusTheme\RadiusBooking\Core\ORM\Relations;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}
/**
 * Core/ORM/Relations/HasMany.php
 * Implements hasMany relationship
 */
class HasMany extends Relation {
	/**
	 * Retrieves an array of related records from the associated model based on the foreign key and local key values.
	 *
	 * @return array The collection of related records.
	 */
	public function get(): array {
		$relatedModel = $this->getRelatedModel();

		return $relatedModel->where( $this->foreignKey, $this->parent->{$this->localKey} )->get();
	}
}
