public function test_shortens_url() { $hash = Little::make('http://laracasts.com'); $this->assertEquals(5, strlen($hash)); $link = Link::whereHash($hash)->first(); $this->assertEquals('http://laracasts.com', $link->url); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { try { $hash = Little::make(Input::get('url')); } catch (ValidationException $e) { return Redirect::home()->withErrors($e->getErrors())->withInput(); } return Redirect::home()->with(['flash_message' => 'Here you go! ' . link_to($hash), 'hashed' => $hash]); }