Skip to content

Hlacos/modelValidation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ModelValidation bundle

Laravel 5 bundle for validate in models.

It's under development, not recommended for production use!

Installation

  1. add bundle to composer: "hlacos/modelValidation": "dev-master"
  2. composer install / update
  3. 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;
}

About

Laravel 5 Eloquent validation bundle

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages