public function postEdit($id) { if (!$this->checkRoute()) { return Redirect::route('index'); } $title = 'Edit A Modpack Code - ' . $this->site_name; $input = Input::only('code', 'launcher', 'modpack'); $modpackcode = ModpackCode::find($id); $messages = ['unique' => 'A code for this launcher/modpack combination already exists in the database!']; $validator = Validator::make($input, ['code' => 'required|unique:modpack_codes,code,' . $modpackcode->id, 'launcher' => 'required', 'modpack' => 'required'], $messages); if ($validator->fails()) { // TODO this line originally redirects to modpack-code/edit, there's no route for this, is this an error? return Redirect::action('ModpackCodeController@getEdit', [$id])->withErrors($validator)->withInput(); } $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.edit', ['title' => $title, 'success' => true, 'modpackcode' => $modpackcode]); } return Redirect::action('ModpackCodeController@getEdit', [$id])->withErrors(['message' => 'Unable to add modpack code.'])->withInput(); }
public function run() { $faker = Faker\Factory::create(); $modpackIds = Modpack::lists('id'); $laucherIds = Launcher::lists('id'); foreach (range(1, 10) as $index) { ModpackCode::create(['code' => $faker->word, 'modpack_id' => $faker->randomElement($modpackIds), 'launcher_id' => $faker->randomElement($laucherIds), 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]); } }