0

Following THIS tutorial, I have modified my rules to

$id = Crypt::decrypt($id); 
$rules = Department::$rules;

$rules['name']              = $rules['name'] . ',id,' . $id;
$rules['department_code']   = $rules['department_code'] . ',id,' . $id;
//dd($rules);
$validator = Validator::make($data = $request->all(), $rules); dd($rules);
if ($validator->fails()) return Redirect::back()->withErrors($validator)->withInput();

in my update() function. But it is showing data already exists ! How to ignore the rules for this ID ?

Community
  • 1
  • 1
Nitish
  • 2,695
  • 9
  • 53
  • 88

1 Answers1

0

Here is my working example which is ignoring the unique rules for the specific ID

'username'          => 'required|unique:users,username,'.$user->id,
Qazi
  • 5,015
  • 8
  • 42
  • 62