public function postTambahUnit(Request $request) { $validator = Validator::make($request->all(), ['nama_unit' => 'required', 'singkatan' => 'required']); $request['created_by'] = Auth::user()->id; if ($validator->fails()) { return redirect()->back()->withErrors($validator)->withInput(); } $input = $request->only(['nama_unit', 'singkatan', 'unit_atasan', 'created_by']); Unit::create($input); return redirect()->back(); }