문제

If I have a route in Laravel

Route::post('/user/{user}/project/{project}/git-add', 'GitController@stageFiles');

How do I access the user and project variables from the controller function being called?

Also, do I need to specify that I am returning a JSON object in the routes file, or is that all taken care of in the controller?

도움이 되었습니까?

해결책

For following route:

Route::post('/user/{user}/project/{project}/git-add', 'GitController@stageFiles');

You need to create stageFiles method in GitController and from your stageFiles method:

public function stageFiles($user, $project)
{
    // $user && $project both are available in this method as parameters
}

다른 팁

This is how you access them:

$user = Input::get('user');
$project = Input::get('project');

And Laravel will understand your json just fine.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top