public function add(Request $request) { $field = new HardwareField(); $field->name = $request->input('name'); $hardware = Hardware::find($request->input('hardware_id')); $field->hardware()->associate($hardware); $field->save(); return redirect()->to(route('hardware.profile', ['id' => $hardware->id]))->with('message_content', '添加成功!')->with('message_type', 'info'); }