I am trying to route to a RESTful controller using the following in app/routes.php:
Route::controller('register', 'RegisterController');
Route::get('/', 'HomeController@showWelcome');
In my app/controllers/RegisterController.php file I have added the following:
<?php
class RegisterController extends BaseController
{
public function getRegister()
{
return View::make('registration');
}
public function postRegister()
{
$data = Input::all();
$rules = array(
'first_name' => array('alpha', 'min:3'),
'last_name' => array('alpha', 'min:3'),
'company_name' => array('alpha_num'),
'phone_number' => 'regex:[0-9()\-]'
);
$validator = Validator::make($data, $rules);
if ($validator->passes()) {
return 'Data was saved.';
}
return Redirect::to('register')->withErrors($validator);
}
}
I am getting the following error:
Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException
When I run php artisan routes in terminal I get:
+--------+--------------------------------------------------+------+----------------------------+----------------+---------------+
| Domain | URI | Name | Action | Before Filters | After Filters |
+--------+--------------------------------------------------+------+----------------------------+----------------+---------------+
| | GET /register/register/{v1}/{v2}/{v3}/{v4}/{v5} | | Register@getRegister | | |
| | POST /register/register/{v1}/{v2}/{v3}/{v4}/{v5} | | Register@postRegister | | |
| | GET /register/{_missing} | | Register@missingMethod | | |
| | GET / | | HomeController@showWelcome | | |
+--------+--------------------------------------------------+------+----------------------------+----------------+---------------+
I don't understand why register is showing twice in the URI and the second GET action is missing and why I am getting this error.