/** * If attribute has a relationship defined, generate the models * @param string $attribute * @return mixed - depends on the relation. usually single model or collection */ protected function getAttributeRelatedModels($attribute) { $method = Str::camel($attribute); if (method_exists($this, $method)) { if ($relation = $this->{$method}() and $relation instanceof Relation) { return $relation->getFromModel($attribute); } } return false; }