imperium2335
imperium2335

Reputation: 24122

Laravel Routing to non index method in controller

I am trying to create a route:

Route::get('/apply/submit', 'ApplyController@submit');

But I keep getting the standard Laravel error page.

My ApplyController:

class ApplyController extends BaseController {

    public function index() {
        return View::make('apply.apply', array('metaTitle' => 'China Aupair | Internships | Apply Online'));
    }

    public function submit() {
        return 'yay!';
    }

}

Which I don't understand because Route::get('/apply', 'ApplyController@index'); works as it should.

What am I doing wrong?

Upvotes: 0

Views: 62

Answers (1)

Marcin Nabiałek
Marcin Nabiałek

Reputation: 111869

I think the problem is the method you access this page. You probably try to send form (using POST method) and you use get for the route. What you should do is change:

Route::get('/apply/submit', 'ApplyController@submit');

into

Route::post('/apply/submit', 'ApplyController@submit');

because you probably send a form and not run this route manually in browser using http://localhost/yourproject/apply/submit

Upvotes: 1

Related Questions