/** * Accept hash, and fetch url * * @param $hash * * @return mixed */ public function processHash($hash) { try { $url = Little::getUrlByHash($hash); return Redirect::to($url); } catch (NonExistentHashException $e) { return Redirect::home()->with('flash_message', 'Sorry - could not find your desired URL.'); } }
public function test_gets_url_by_hash() { Link::create(['url' => 'http://laracasts.com', 'hash' => 'asdfg']); $url = Little::getUrlByHash('asdfg'); $this->assertEquals('http://laracasts.com', $url); }