简体   繁体   中英

laravel “get” parameter not working

I am having a bit of difficulty with something simple.

If I visit test.dev/test/1, I get the following error

Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException

Controller method not found.

my controller

<?php

class TestController extends BaseController {

    public function getIndex($id)
    {
        return View::make('test.index');
    }

}

If I remove The $id from the controller and take the 1 out of the url it works.

Any ideas?

I think you've missed the parameter in your route declaration. Check the docs for Route Parameters .

Check if your route is declared properly. It should look something like this

Route::get(test/{id}, TestController@getIndex)

Notice the {id} - that's the parameter you are passing to the getIndex() method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM