Skip to content

Commit

Permalink
add DB validation rule info to readme (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
mallardduck authored Aug 18, 2021
1 parent 9bb6f69 commit 9139590
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,17 @@ User::with('role')->first();

> Note: There is one caveat when dealing with Sushi model relationships. The `whereHas` method will NOT work. This is because the two models are spread across two separate databases.
### Using database-checking validation rules
You can even use Laravel's `exists:table,column` database checking request validation rule.

```php
$data = request()->validate([
'state' => ['required', 'exists:App\Model\State,abbr'],
]);
```

> Note: Be aware that you must use the fully-qualified namespace of the model instead of a table name. This ensures that Laravel will correctly resolve the model's connection.
### Custom Schema
If Sushi's schema auto-detection system doesn't meet your specific requirements for the supplied row data, you can customize them with the `$schema` property or the `getSchema()` method.

Expand Down

0 comments on commit 9139590

Please sign in to comment.