Skip to content

Commit

Permalink
chore: fix docs for with() method
Browse files Browse the repository at this point in the history
  • Loading branch information
roxblnfk committed Jun 5, 2024
1 parent c31846b commit f3492f9
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/Select.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,25 +375,20 @@ public function load(string|array $relation, array $options = []): self
* ->load('comments', ['using' => 'commentsR']);
* ```
*
* To use `with` twice on the same relation you can use `alias` option.
* To use with() twice on the same relation, you can use `alias` option.
* ```php
* Country::find()
* // Find all translations
* ->with('translations', [ 'as' => 'trans'])
* ->where(function (QueryBuilder $qb): void {
* $searchProperties = ['code', 'name', 'trans.title'];
* foreach ($searchProperties as $propertyName) {
* $qb->orWhere($propertyName, 'LIKE', '%eng%');
* }
* })
* ->load('translations', ['using' => 'trans'])
* // Second `with`
* // Second `with` for sorting only
* ->with('translations', [
* 'as' => 'comments2', // Alias for SQL
* 'alias' => 'comments_sort', // Alias for ORM to not overwrite previous `with` call
* 'as' => 'transEn', // Alias for SQL
* 'alias' => 'translations-en', // Alias for ORM to not to overwrite previous `with`
* 'method' => JoinableLoader::LEFT_JOIN,
* 'where' => ['author_id' => $id],
* ]);
* 'where' => ['locale' => 'en'],
* ])
* ->orderBy('transEn.title', 'ASC');
* ```
*
* @return static<TEntity>
Expand Down

0 comments on commit f3492f9

Please sign in to comment.