Search code examples
phpcontrollerlaravellaravel-4restful-architecture

Laravel 4 - New and I'm stuck already


I'm new to Laravel 4 and I'm stuck already... I can't seem to get my head around routes.

I keep getting this error, when I go to the following URL account/welcome/Scott/UK:

    Missing argument 2 for Illuminate\Routing\Controller::missingMethod()

This is what is in my routes file:

    Route::controller('account', 'AccountController');

And this is in my controller:

public function action_welcome($name, $place)
{

      echo "Welcome to {$place}, {$name}!";

}

Can anyone shed any light on this? It must be something really simple.


Solution

  • This is the proper syntax for actions in a Laravel 4 RESTful Controller:

    class GenericController extends Controller {
    
        public function getWelcome($name, $place)
        {
    
              echo "Welcome to {$place}, {$name}!";
    
        }
    
        public function postLogin()
        {
    
              ...
    
        }
    
    }
    

    You can see if it's right by executing

    php artisan routes