Advertisement
Guest User

Untitled

a guest
Jan 30th, 2015
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1.  
  2. //My isValid function inside Users.php model
  3. public function isValid($id = null)
  4. {
  5. // If we are updating, ignore the unique username rule by adding user id to rules array.
  6. $rules = array(
  7. 'email' => 'required|max:100|unique:users,email,' . $id,
  8. 'username' => 'required|max:32|unique:users,' . $id
  9. );
  10. $validation = Validator::make($this->attributes, $rules, static::$validationMessages);
  11.  
  12. if ($validation->passes()){
  13. return true;
  14. }
  15. $this->messages = $validation->messages();
  16. return false;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement