*/ public function rules() : array { return [ 'kode' => 'required|string|unique:documents,kode,' . $this->id, 'directorat_id' => 'required|integer|exists:directorats,id', 'sub_directorat_id' => 'required|integer|exists:sub_directorats,id', 'job_id' => 'required|integer|exists:jobs,id', 'sub_job_id' => 'required|integer|exists:sub_jobs,id', 'sub_sub_job_id' => 'required|integer|exists:sub_sub_jobs,id', 'special_code_id' => 'nullable|integer|exists:special_codes,id', 'no_urut' => 'nullable|integer|min:1|max:999', 'sequence' => 'nullable|integer|min:1|max:999', 'status' => 'nullable|integer', 'keterangan' => 'nullable|string|max:255', 'jenis_dokumen' => 'nullable|string|max:255', ]; } /** * 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('document.index')->with('error', 'Document updated failed.'); } }); } }