3

I'm new to laravel 4 and I'm currently having the following problem: In my routes.php I have the line:

Route::get('maps/{map_type}', 'MapsController@loadMaps');

And in my MapsController I'd like to get the {map_type} to use it.

So my question: How can I retrieve map_type in my Controller?

2 Answers 2

4

Your first argument in your loadMaps method is your map type.

public function loadMaps($map_type) {
    return $map_type;
}

Take a look at the first two code snippets on http://laravel.com/docs/controllers.

Sign up to request clarification or add additional context in comments.

Comments

1

Controllers receive parameters as parameters in the called function:

class MapsController extends BaseController {
    public function loadMaps($map_type) {}
}

Check http://laravel.com/docs/controllers#basic-controllers for more info

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.