Skip to content

Commit

Permalink
Resource routes documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
andersonsalas committed Jul 12, 2018
1 parent c466a4d commit 5fdcbe7
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 7 deletions.
4 changes: 1 addition & 3 deletions docs/en/001_welcome.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,4 @@ Luthier CI is installed through Composer and uses CodeIgniter _hooks_ to integra

### Community and support

To report errors and propose changes please visit the [Luthier CI repository on Github](https://github.com/ingeniasoftware/luthier-ci) and make your requests there.

Also, we have put at your disposal a [thread in the CodeIgniter forum](https://forum.codeigniter.com/thread-70497.html) where you can share your doubts about the project and receive support.
To report errors and propose changes please visit the [Luthier CI repository on Github](https://github.com/ingeniasoftware/luthier-ci)
36 changes: 36 additions & 0 deletions docs/en/003_routes.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
3. [Named routes](#named-routes)
4. [Callbacks as routes](#callbacks-as-routes)
5. [Groups](#groups)
5. [Resource routes](#resource-routes)
6. [Default controller](#default-controller)
4. [Parameters](#parameters)
1. [Optional parameters](#optional-parameters)
Expand Down Expand Up @@ -146,6 +147,41 @@ Route::group('prefix', ['namespace' => 'foo', 'middleware' => ['Admin','IPFilter
});
```

#### <a name="resource-routes"></a> Resource routes

Resource routes allow you to define CRUD operations (**C**reate, **R**ead, **U**pdate, **D**elete) for a controller on a single line. Example:

```php
Route::resource('photos','PhotosController');
```

Produces:

```php
[Name] [Path] [Verb] [Controller action]
photos.index photos GET PhotosController@index
photos.create photos/create GET PhotosController@create
photos.store photos POST PhotosController@store
photos.show photos/{id} GET PhotosController@show
photos.edit photos/{id}/edit GET PhotosController@edit
photos.update photos/{id} PUT, PATCH PhotosController@update
photos.destroy photos/{id} DELETE PhotosController@destroy
```

In addition, it is possible to create partial resource routes, passing a third argument with an array of the actions to be filtered:

```php
Route::resource('photos','PhotosController', ['index','edit','update']);
```

Produces:

```php
[Name] [Path] [Verb] [Controller action]
photos.index photos GET PhotosController@index
photos.edit photos/{id}/edit GET PhotosController@edit
photos.update photos/{id} PUT, PATCH PhotosController@update

#### <a name="default-controller"></a> Default controller

Luthier CI automatically sets any route defined with the URL **/** and the HTTP verb **GET** as the default controller, however you can explicitly set it using the `set()` method and this special syntax:
Expand Down
4 changes: 1 addition & 3 deletions docs/es/001_welcome.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,4 @@ Luthier CI se instala a través de Composer y utiliza los _hooks_ de CodeIgniter

### Comunidad y soporte

Para reportar errores y proponer cambios por favor visita el repositorio de [Luthier CI en Github](https://github.com/ingeniasoftware/luthier-ci) y haz tus solicitudes allí.

También, hemos puesto a tu disposición un [hilo en el foro de CodeIgniter](https://forum.codeigniter.com/thread-70497.html) (en inglés) donde puedes compartir tus dudas sobre el proyecto y recibir soporte.
Para reportar errores y proponer cambios por favor visita el repositorio de [Luthier CI en Github](https://github.com/ingeniasoftware/luthier-ci)
39 changes: 38 additions & 1 deletion docs/es/003_routes.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
3. [Rutas con nombre](#named-routes)
4. [Funciones anónimas como rutas](#callbacks-as-routes)
5. [Grupos](#groups)
6. [Controlador por defecto](#default-controller)
6. [Rutas de recurso](#resource-routes)
7. [Controlador por defecto](#default-controller)
4. [Parámetros](#parameters)
1. [Parámetros opcionales](#optional-parameters)
2. [Expresiones regulares en parámetros](#parameter-regex)
Expand Down Expand Up @@ -144,6 +145,42 @@ Route::group('prefix', ['namespace' => 'foo', 'middleware' => ['Admin','IPFilter
});
```

#### <a name="resource-routes"></a> Rutas de recurso

Las rutas de recurso permiten definir operaciones de CRUD (**C**reate, **R**ead, **U**pdate, **D**elete) para un controlador en una sola línea. Ejemplo:

```php
Route::resource('photos','PhotosController');
```

Produce:

```php
[Name] [Path] [Verb] [Controller action]
photos.index photos GET PhotosController@index
photos.create photos/create GET PhotosController@create
photos.store photos POST PhotosController@store
photos.show photos/{id} GET PhotosController@show
photos.edit photos/{id}/edit GET PhotosController@edit
photos.update photos/{id} PUT, PATCH PhotosController@update
photos.destroy photos/{id} DELETE PhotosController@destroy
```

Además, es posible crear rutas de recurso parciales, pasando un tercer argumento con un arreglo de las acciones a filtrar:

```php
Route::resource('photos','PhotosController', ['index','edit','update']);
```

Produce:

```php
[Name] [Path] [Verb] [Controller action]
photos.index photos GET PhotosController@index
photos.edit photos/{id}/edit GET PhotosController@edit
photos.update photos/{id} PUT, PATCH PhotosController@update
```

#### <a name="default-controller"></a> Controlador por defecto

Luthier CI establece automáticamente cualquier ruta definida con la URL `/` y el verbo HTTP **GET** como el controlador por defecto, sin embargo puedes establecerlo explícitamente mediante el método `set()` y esta sintaxis especial:
Expand Down

0 comments on commit 5fdcbe7

Please sign in to comment.