Creating a RESTful controller
There may be a time when we want to have a RESTful web application, such as when building an API. To accomplish this, we need our routes to respond to various HTTP requests. The routes with closures are already set up this way, but in this recipe, we'll stay in the MVC pattern and create a controller that is RESTful.
Getting ready
For this recipe, we need a standard Laravel installation and the code from the Creating a basic controller recipe.
How to do it...
To complete this recipe, follow these steps:
In the User controller, replace the code with the following code:
<?php class UsersController extends BaseController { public function getIndex() { $my_form = "<form method='post'> <input name='text' value='Testing'> <input type='submit'> </form>"; return $my_form; } public function postIndex() { dd(Input::all()); } public function getAbout() ...