I have problem with validate when i edit my user. So when i edit i get message that name is already taken. How can i fix this? Because that name belongs to that user. So i need to change name again so that i can edit my user.
if($user->business_user){
$this->validate($request,[
'company_name' => 'required|unique:business_users'
]);
}
My view:
<div class="col-md-6 col-sm-6 col-xs-12">
<div class="form-group" v-bind:class="{ 'has-error': basic_errors.company_name }">
<label class="form_title">COMPANY NAME</label>
<input type="text" name="company_name" v-model="basic_credentials.company_name" value="{{ is_value_empty($user->business_user->company_name) }}" class="form_input">
<span class="help-block" id="helpBlock2" v-show="basic_errors.company_name">@{{ basic_errors.company_name }}</span>
</div>
</div>
You can check this validation
https://laravel.com/docs/5.3/validation#rule-unique