From 9139590922edfa1db61e9aa49401889e85ed3b5f Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 18 Aug 2021 10:28:54 -0400 Subject: [PATCH] add DB validation rule info to readme (#95) --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index 6454d5e..f6a6da6 100644 --- a/README.md +++ b/README.md @@ -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.