Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to pass multiple optional parameters using Laravel 4.x

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 753
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: