As we all know that routes plays an important role in any MVC framework. In Laravel we will define our routes in routes.php. Using Laravel 4.x we have the option to pass multiple optional parameters using Laravel 4.x.
By using example it can be easily explained
Example:
Route::get('test',array('as'=>'test','uses'=>'HomeController@index'));
By this way we can define our routes in routes.php.
And inside the controller HomesController.php we will write:
class HomeController extends BaseController {
public function index()
{
// for example public/test/id=1&page=2&opt=1
if(Input::has('id'))
echo Input::get('id'); // print 1
if(Input::has('page'))
echo Input::get('page'); // print 2
//...
}
}
By this way we can pass multiple optional parameters using Laravel 4.x.
0 Comment(s)