public function postAdd() { if (!$this->checkRoute()) { return Redirect::route('index'); } $title = 'Add A Modpack Code - ' . $this->site_name; $input = Input::only('code', 'launcher', 'modpack'); $messages = ['unique' => 'A code for this launcher/modpack combination already exists in the database!']; $validator = Validator::make($input, ['code' => 'required|unique:modpack_codes,code', 'launcher' => 'required', 'modpack' => 'required'], $messages); if ($validator->fails()) { // TODO this line originally redirects to modpack-code/add, there's no route for this, is this an error? return Redirect::action('ModpackCodeController@getAdd')->withErrors($validator)->withInput(); } $modpackcode = new ModpackCode(); $modpackcode->code = $input['code']; $modpackcode->modpack_id = $input['modpack']; $modpackcode->launcher_id = $input['launcher']; $modpackcode->last_ip = Request::getClientIp(); $success = $modpackcode->save(); if ($success) { Cache::tags('modpacks')->flush(); Queue::push('BuildCache'); return View::make('modpackcodes.add', ['title' => $title, 'success' => true]); } return Redirect::action('ModpackCodeController@getAdd')->withErrors(['message' => 'Unable to add modpack code.'])->withInput(); }