File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -540,6 +540,15 @@ public function refresh(): bool
540540 return $ this ->refreshInternal ($ record );
541541 }
542542
543+ public function relation (string $ name ): ActiveRecordInterface |array |null
544+ {
545+ if (array_key_exists ($ name , $ this ->related )) {
546+ return $ this ->related [$ name ];
547+ }
548+
549+ return $ this ->retrieveRelation ($ name );
550+ }
551+
543552 public function resetRelation (string $ name ): void
544553 {
545554 foreach ($ this ->relationsDependencies as &$ relationNames ) {
Original file line number Diff line number Diff line change @@ -187,6 +187,15 @@ public function getOldPrimaryKey(bool $asArray = false): mixed;
187187 */
188188 public function getPrimaryKey (bool $ asArray = false ): mixed ;
189189
190+ /**
191+ * Returns the relation object with the specified name.
192+ *
193+ * @param string $name The relation name (case-sensitive).
194+ *
195+ * @return ActiveRecordInterface|array|null The relation object.
196+ */
197+ public function relation (string $ name ): self |array |null ;
198+
190199 /**
191200 * Returns the relation object with the specified name.
192201 *
You can’t perform that action at this time.
0 commit comments