Skip to content

Instantly share code, notes, and snippets.

@Artistan
Created September 4, 2018 14:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Artistan/566f2d971088af2c811ade2aaa51c462 to your computer and use it in GitHub Desktop.
Save Artistan/566f2d971088af2c811ade2aaa51c462 to your computer and use it in GitHub Desktop.
Laravel API routes
<?php
use Illuminate\Http\Request;
// api auth routes...
Route::group(['middleware' => ['auth:api']], function () {
// unversioned api routes
Route::get('/user', function (Request $request) {
return $request->user();
});
// version 1
Route::group(['prefix' => 'v1'], function () {
Route::apiResource('documents', 'DocumentsController');
});
});
@Artistan
Copy link
Author

Artistan commented Sep 4, 2018

|        | GET|HEAD  | api/user                                |                                 | Closure                                                                  | api,auth:api                                     |
|        | GET|HEAD  | api/v1/documents                        | documents.index                 | App\Http\Controllers\DocumentsController@index                           | api,auth:api                                     |
|        | POST      | api/v1/documents                        | documents.store                 | App\Http\Controllers\DocumentsController@store                           | api,auth:api                                     |
|        | DELETE    | api/v1/documents/{document}             | documents.destroy               | App\Http\Controllers\DocumentsController@destroy                         | api,auth:api                                     |
|        | PUT|PATCH | api/v1/documents/{document}             | documents.update                | App\Http\Controllers\DocumentsController@update                          | api,auth:api                                     |
|        | GET|HEAD  | api/v1/documents/{document}             | documents.show                  | App\Http\Controllers\DocumentsController@show                            | api,auth:api

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment