File tree Expand file tree Collapse file tree 1 file changed +3
-5
lines changed
Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Original file line number Diff line number Diff line change @@ -33,8 +33,8 @@ composer require steven-fox/laravel-model-validation
3333
3434### The ` ValidatesAttributes ` Trait
3535Add validation functionality to a Model by:
36- 1 . Adding the ` \ StevenFox\LaravelModelValidation\ValidatesAttributes` trait to the model.
37- 2 . Defining the rules via the ` commonValidationRules(): array ` method.
36+ 1 . Adding the ` StevenFox\LaravelModelValidation\ValidatesAttributes ` trait to the model.
37+ 2 . Defining the rules via the ` commonValidationRules() ` method.
3838
3939``` php
4040use Illuminate\Database\Eloquent\Model;
@@ -44,7 +44,7 @@ class ValidatingModel extends Model
4444{
4545 use ValidatesAttributes;
4646
47- protected function commonValidationRules() : array
47+ protected function commonValidationRules(): array
4848 {
4949 return [
5050 // rules go here as ['attribute' => ['rule1', 'rule2', ...]
@@ -57,8 +57,6 @@ $model = new ValidatingModel($request->json());
5757
5858$model->validate(); // A ModelValidationException is thrown if validation fails.
5959$model->save();
60- $validator = $model->validator();
61- $validatedData = $validator->validated();
6260
6361// Other helpful methods...
6462$passes = $model->passesValidation(); // An exception, will *not* be thrown if validation fails.
You can’t perform that action at this time.
0 commit comments