Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion database/relations.md
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,18 @@ You may also specify an operator and count to further customize the query:
$posts = Post::has('comments', '>=', 3)->get();
```

> **NOTE**: MySQL strict mode can sometimes complain when using a `GROUP` column without a `GROUP BY` clause (in the above case, `COUNT()`). You can set the `strict` option to `false` in your database's connection configuration (i.e. `database.connections.mysql.strict`) to ignore this warning message.
> **NOTE**: MySQL strict mode can sometimes complain when using a `GROUP` column without a `GROUP BY` clause (in the above case, `COUNT()`). To ignore this warning message, you can set the `strict` option to `false` in your database's connection configuration (i.e. `database.connections.mysql.strict`) or disable the `strict` option the time of running your query (see below).

```php
// Disable mysql strict mode
config()->set('database.connections.mysql.strict', false);
DB::reconnect();
// Retrieve all posts that have three or more comments...
$posts = Post::has('comments', '>=', 3)->get();
// Re-enable mysql strict mode
config()->set('database.connections.mysql.strict', true);
DB::reconnect();
```

Nested `has` statements may also be constructed using "dot" notation. For example, you may retrieve all posts that have at least one comment and vote:

Expand Down