Skip to content

Commit dedd1b7

Browse files
committed
add Model::has() and Model::hasNo() to docs
1 parent 4790e30 commit dedd1b7

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

v5/relationships.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@ You can scope any inner relationship as well by passing a callback.
284284

285285
```php
286286
<?php
287+
use TypeRocket\Models\Model;
288+
287289
class ExampleModel extends Model
288290
{
289291
public function publishedBlog()
@@ -326,4 +328,13 @@ class ExampleModel extends Model
326328
});
327329
}
328330
}
331+
```
332+
333+
## Querying Relationship Existence
334+
335+
When retrieving model records, you can limit your results based on the existence of a relationship. To do so, you may pass the name of the relationship to the `has()` and `hasNo()` methods:
336+
337+
```php
338+
ExampleModel::new()->has('tags')->get();
339+
ExampleModel::new()->hasNo('tags')->get();
329340
```

0 commit comments

Comments
 (0)