PHPackages                             anourvalar/eloquent-validation - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. anourvalar/eloquent-validation

ActiveLibrary[Database &amp; ORM](/categories/database)

anourvalar/eloquent-validation
==============================

Validation feature for eloquent model (Laravel)

3.17.7(3d ago)012.3k↓26.8%[1 PRs](https://github.com/AnourValar/eloquent-validation/pulls)3MITPHPPHP ^8.3CI failing

Since Nov 7Pushed 3d ago1 watchersCompare

[ Source](https://github.com/AnourValar/eloquent-validation)[ Packagist](https://packagist.org/packages/anourvalar/eloquent-validation)[ Docs](https://github.com/AnourValar/eloquent-validation)[ RSS](/packages/anourvalar-eloquent-validation/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (25)Versions (163)Used By (3)

Validation for Eloquent Models
==============================

[](#validation-for-eloquent-models)

Installation
------------

[](#installation)

```
composer require anourvalar/eloquent-validation
```

Usage
-----

[](#usage)

### Creating with validation

[](#creating-with-validation)

```
\App\UserPhone
    ::fields('user_id', 'phone_number') // fillable columns (mass assignment)
    ->fill(\Request::input())
    ->validate() // will throw exception if it fails
    ->save();
}
```

### Updating with validation

[](#updating-with-validation)

```
\App\UserPhone
    ::findOrFail(\Request::input('id'))
    ->fields(['user_id', 'phone_number']) // also might be an array
    ->fill(\Request::input())
    ->validate()
    ->save();
}
```

Generate model
--------------

[](#generate-model)

```
php artisan make:model-validation UserPhone
```

Model configuration
-------------------

[](#model-configuration)

```
