Hi all, i have an app that provides registration users and edit information account.
In registration phase the email is required but when a user try to edit his information account. i don't want give the possibility to edit the email.
How can i make this possibile using the same validation rules in model User?
thanks
Try something like this:
$rules = [
// Validation rules
"firstname" => "required",
"lastname" => "required",
"phone" => "required"
];
$messages = [
// Custom error messages
"firstname.required" => "Please enter your first name.",
"lastname.required" => "Please enter your last namer.",
"phone.required" => "Please enter a phone number where you can be reached."
];
if(Input::get('action') == "create") { // Example, check if the user is beeing created
// Add new rules
$rules["email"] = "required|email";
$messages["email.required"] = "Please enter an email address.";
$messages["email.email"] = "Please enter a valid email address.";
}
$validator = Validator::make(Input::all(), $rules, $messages);
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community