Skip to content

Commit

Permalink
Update relations.md
Browse files Browse the repository at this point in the history
  • Loading branch information
bennothommo authored Mar 1, 2024
1 parent 0c96f5d commit e0f4393
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion database/relations.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,15 @@ Method | Description
You might have noticed that there are no chain methods for handling "constraint" options like the `order`, `conditions` and `scope` options available in the property style relations. That is because relations defined in this format are already [query builders](query) - you can simply add the constraints directly to the relation!

```php
public function posts(): HasMany
#[Relation]
public function posts()
{
return $this->hasMany('Acme\Blog\Models\Post')->dependent()->published()->where('free_article', true);
}
```

> **Note:** If your relation is constrained in this fashion, the object returned will be a query builder, not the original relation class. You will need to use the `Relation` attribute to mark methods that return query builders as a relation method.
## Relationship types

The following relations types are available:
Expand Down

0 comments on commit e0f4393

Please sign in to comment.