![]() If a controller action is particularly complex, you might find it convenient to dedicate an entire controller class to that single action. However, you will not have access to convenient features such as the middleware and authorize methods. Route::get('/user/ Controllers are not required to extend a base class. ![]() You can define a route to this controller method like so: use App\Http\Controllers\UserController Note that the controller extends the base controller class included with Laravel: App\Http\Controllers\Controller: User::findOrFail($id) Let's take a look at an example of a basic controller. By default, controllers are stored in the app/Http/Controllers directory. For example, a UserController class might handle all incoming requests related to users, including showing, creating, updating, and deleting users. Controllers can group related request handling logic into a single class. ![]() Instead of defining all of your request handling logic as closures in your route files, you may wish to organize this behavior using "controller" classes.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |