*/ public function rules(): array { return [ 'kode' => 'required|string|max:2|min:2|unique:special_codes,kode,'.$this->id, 'name' => 'required|string|max:50' ]; } /** * Configure the validator instance. */ public function withValidator(Validator $validator): void { $validator->after(function (Validator $validator) { if($validator->errors()->any()) { $error = json_decode($validator->errors()->toJson(), true); foreach ($error as $key => $value) { flash( $value[0]); } return redirect()->route('special-code.index')->with('error', 'Special Code updated failed.'); } }); } }