Skip to content

Instantly share code, notes, and snippets.

@dadamssg
Last active December 25, 2015 17:59
Show Gist options
  • Save dadamssg/7017363 to your computer and use it in GitHub Desktop.
Save dadamssg/7017363 to your computer and use it in GitHub Desktop.
<?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