Search code examples
functioncodeignitervariableslaravel-4laravel-3

Laravel Equivalent of passing variables to functions in codeigniter


I am using CodeIgniter from 2 years and i am trying to move to Laravel and I saw many tutorials of how to use Laravel but i couldn't find any answers to how to pass variables to functions using the URL and without using routes like in CodeIgniter if i called this link site.com/users/edit/12.

I would be calling the users controller , the edit function and passing a variable of value 12 how can i do the same in Laravel without using routes for every single function or using query strings which will make the URL ugly?


Solution

  • Here is an example.Hope that it will be helpful.......

    route.php

    Route::controller('users','UsersController');
    

    UsersController.php

    class UsersController extends BaseController
    {       
    
        public function getEdit($value)
        {
            echo $value;
        }
    }
    

    url

    site.com/users/edit/12
    

    output

    12