master

laravel/framework

Last updated at: 29/12/2023 09:21

SupportsPartialRelations.php

TLDR

This file defines an interface called SupportsPartialRelations in the Illuminate\Contracts\Database\Eloquent namespace.

Methods

ofMany

This method is used to indicate that the relation is a single result of a larger one-to-many relationship.

  • Parameters:
    • $column (optional): the column name that identifies the relation. Default value is 'id'.
    • $aggregate (optional): the aggregate function to apply to the relation. Default value is 'MAX'.
    • $relation (optional): the name of the relation. Default value is null.
  • Returns: $this (the object implementing the interface)

isOneOfMany

This method is used to determine whether the relationship is a one-of-many relationship.

  • Returns: bool (true if the relationship is a one-of-many relationship, false otherwise)

getOneOfManySubQuery

This method is used to get the one of many inner join subselect query builder instance.

  • Returns: \Illuminate\Database\Eloquent\Builder|void (the query builder instance or void if not applicable)
<?php

namespace Illuminate\Contracts\Database\Eloquent;

interface SupportsPartialRelations
{
    /**
     * Indicate that the relation is a single result of a larger one-to-many relationship.
     *
     * @param  string|null  $column
     * @param  string|\Closure|null  $aggregate
     * @param  string  $relation
     * @return $this
     */
    public function ofMany($column = 'id', $aggregate = 'MAX', $relation = null);

    /**
     * Determine whether the relationship is a one-of-many relationship.
     *
     * @return bool
     */
    public function isOneOfMany();

    /**
     * Get the one of many inner join subselect query builder instance.
     *
     * @return \Illuminate\Database\Eloquent\Builder|void
     */
    public function getOneOfManySubQuery();
}