Illuminate\Database\Eloquent\Model::getRelationshipFromMethod PHP Метод

getRelationshipFromMethod() защищенный Метод

Get a relationship value from a method.
protected getRelationshipFromMethod ( string $method ) : mixed
$method string
Результат mixed
    protected function getRelationshipFromMethod($method)
    {
        $relations = $this->{$method}();
        if (!$relations instanceof Relation) {
            throw new LogicException('Relationship method must return an object of type ' . 'Illuminate\\Database\\Eloquent\\Relations\\Relation');
        }
        $this->setRelation($method, $results = $relations->getResults());
        return $results;
    }

Usage Example

Пример #1
0
 protected function getRelationshipFromMethod($method)
 {
     $models = parent::getRelationshipFromMethod($method);
     !is_null($models) ?: ($models = $this->{$method}()->newQuery()->getModel());
     return $this->relations[$method] = $models;
 }
Model