hlacos / model_validation
There is no license information available for the latest version (dev-master) of this package.
dev-master
2015-06-02 15:12 UTC
Requires
- php: >=5.4.0
- illuminate/support: 5.0.*
This package is auto-updated.
Last update: 2024-11-13 23:08:52 UTC
README
Laravel 5 bundle for validate in models.
It's under development, not recommended for production use!
Installation
- add bundle to composer: "hlacos/modelValidation": "dev-master"
- composer install / update
- add service provider to the providers list: 'Hlacos\ModelValidation\ModelValidationServiceProvider'
Usage
In the rules array use the laravel validator formats.
class CustomModel extends Eloquent { use ModelValidationTrait; public $rules = array( 'attribute' => 'required', ); } $customModel = new CustomModel(); $customModel->setAttributes($attributes); if ($customModel->isValid()) { $customModel->save(); } else { return $customModel->errors; }