Set Nice Names For Validation Attributes in Laravel

Here’s a simple trick which allows you to change :attribute name ( e.g. first_name ) with a more proper and easy to read name ( e.g. First name ).

Quick Tip : Set Timezone in Laravel

To do this, we are going to use setAttributeNames method.

$nice_names = array(
    'first_name' => 'First Name'
);

$validator = Validator::make(Input::all(), $rules);
$validator->setAttributeNames($nice_names);

 

0 Comments

Leave a Comment.