vendredi 14 octobre 2016

Laravel custom error messages for same rule used twice

I am trying to create different custom error messages on the same rule used twice or more in my Laravel 5.0 validator method.

$messages = [ 'exists'    => 'The order finished',
              'exists'    => 'The order belong to another user.' ];   
$validator = Validator::make( ['order_id' => $order_id], 
                              ['order_id' => "required|exists:t_orders,channel_id,finished,0|exists:t_orders,channel_id,user_id,$user_id"], 
$messages);

However, whichever order the validation applies, only the last custom error message is returned.

Is there a way I use the same rule twice or more times and create different custom error messages for each?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire