I am new to Laravel. I want port a URL shortening application from CI to Laravel. I am struck on the first step. I want to use the following routes in Laravel. Please help me port it.
$route['(:any)'] = "redirect/index/$1";
$route['shorten/create'] = "shorten/create"; // overwrite the previous route
$route['stats/view'] = "stats/view"; // allow the tats controller to be used
$route['default_controller'] = "shorten";
$route['404_override'] = '404';
I have helped to port the first the three routes for you. I suggest you to read up on laravel routing at http://laravel.com/docs/routing
Route::get('/redirect/index/{any}', array('uses' => 'ControllerName@FunctionName'));
Route::get('/shorten/create', array('uses' => 'ControllerName@FunctionName'));
Route::get('/stats/view', array('uses' => 'ControllerName@FunctionName'));
This is how I would have done it.
<?php
Route::get('shorten/create', [
'as' => 'createUrl',
'uses' => 'ShortenController@getCreate'
]);
Route::get('stats/view', [
'as' => 'statsView',
'uses' => 'StatsController@getView'
]);
Route::get('/', [
'as' => 'index',
'uses' => 'ShortenController@getIndex'
]);
Route::get('{shortUrl}', [
'as' => 'url',
'uses' => 'ShortenController@getUrl'
]);
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community