/** * New page (post). * * @Post("new", as="admin.shorturl.new") * * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function postNew() { $data = $this->request()->all(); $data['hash'] = str_random(5); $validate = $this->shortURL->insert($data, ['save' => true]); if ($validate === true) { return redirect('admin/shorturl/all')->with('message', '作成しました。'); } return redirect()->back()->withErrors($validate->errors()); }
/** * Test insert method. * * @dataProvider insertDataProvider * * @param mixed $hash * @param mixed $url * @param bool $hasError */ public function testInsert($hash, $url, $hasError) { $data = compact('hash', 'url'); $response = $this->shortURL->insert($data); $this->checkError($response, $hasError); }