Last active
December 25, 2015 17:59
-
-
Save dadamssg/7017363 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace ProgrammingAreHard\Data\Validators; | |
class UserValidation implements HasModelRules { | |
/** | |
* Laravel validation ruleset for model creation | |
* | |
* @var array | |
*/ | |
private static $rulesForCreate = [ | |
'email' => 'required|email|unique:users', | |
'password' => 'required|confirmed' | |
]; | |
/** | |
* Laravel validation ruleset for updating model | |
* | |
* @var array | |
*/ | |
private static $rulesForUpdate = [ | |
'email' => 'required|email|unique:users', | |
]; | |
/** | |
* Get the Eloquent validation rules for the model | |
* | |
* @return array | |
*/ | |
public function getRulesForCreate() | |
{ | |
return self::$rulesForCreate; | |
} | |
/** | |
* Get the validation rules for the model when updating | |
* | |
* @return array | |
*/ | |
public function getRulesForUpdate() | |
{ | |
return self::$rulesForUpdate; | |
} | |
/** | |
* Get all the user field names | |
* | |
* @return array | |
*/ | |
public function getFields() | |
{ | |
return ['email', 'password', 'first_name', 'last_name']; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment