rydurham / Sentinel

A Sentry bridge package for Laravel
http://www.ryandurham.com/projects/sentinel/
317 stars 68 forks source link

Override Validation on user create #210

Closed yokimohan123 closed 8 years ago

yokimohan123 commented 8 years ago

Hello rydurham, I have added three more fields on the user creation form, i need to implement the validation for 1)first_name, 2)last_name and 3)country so i have tried to implement from the vendor folder, from validation the file path from vendor folder is: vendor\rydurham\sentinel\src\Sentinel\FormRequests\UserCreateRequest.php to added those fields on rules variable but once i update the composer it's not working or it's updated to existing rules on the fields, so how should i overcome this issue or how to do the validation for custom fields thanks in advance.

rydurham commented 8 years ago

Generally speaking, it is considered best practice to not edit any code in the vendor directory directly. In this case, there are alternate methods that can achieve the same goal. (See #205 )

If you have not done so already, publish the configuration file to your config directory (see the readme for instructions.) In that file there is an array called "additional_user_fields"; you can use this array to set validation rules for new or existing attributes of your user model.

yokimohan123 commented 8 years ago

Thanks alot for your quick reply, and i agree with your point, but my User Model is not working any more, because it's already working based on the rydurham/Sentinel User model so in my User Model i need to extend to your rydurham/Sentinel Model, if so how to extend normal user model to rydurham/Sentinel user model, thanks in advance.

rydurham commented 8 years ago

Have your user model extend 'Sentinel\Models\User' and edit the Sentry config file to indicate the full namespace of your new user model. Make sure you are editing the sentry config file that was published to your application when you ran the Sentinel publish command.

rydurham commented 8 years ago

Closing for lack of activity.