Pregunta

I want Ardent to check that password and password confirmation match...yet, I obviously don't want to store password confirmation in the database. So how do I get Ardent to do it's stuff and validate but not try to save the password confirmation?

Note: the validation is failing anyway as it is not seeing the password_confirmation property value. I imagine it's looking for it under the model attributes, whereas I have just set it as a private property. If I set it as the model's attribute though, it will try to save this to the database.

public static $rules = array(
        'email' => 'required|email',
        'first_name' => 'required|alphaNum|min:3',
        'surname' => 'required|alphaNum|min:3',
        'password' => 'required|alphaNum|min:6|confirmed',
        'password_confirmation' => 'required'
);

//user object gets populated
$this->save(); 
¿Fue útil?

Solución

You give your class a property of

public $autoPurgeRedundantAttributes = true;

And that automatically purges any properties not used in the database, see here.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top