Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //My isValid function inside Users.php model
- public function isValid($id = null)
- {
- // If we are updating, ignore the unique username rule by adding user id to rules array.
- $rules = array(
- 'email' => 'required|max:100|unique:users,email,' . $id,
- 'username' => 'required|max:32|unique:users,' . $id
- );
- $validation = Validator::make($this->attributes, $rules, static::$validationMessages);
- if ($validation->passes()){
- return true;
- }
- $this->messages = $validation->messages();
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement