vendredi 25 novembre 2016

Laravel edit routing best practice

In laravel 5.2 basic task list tutorial there are three routes:

Route::get('/', function () { /**/ });
Route::post('/task', function (Request $request) { /**/ });
Route::delete('/task/{task}', function (Task $task) { /**/ });

The first is for listing tasks, the second for adding a task and the last for deleting a task. In the tutorial the listing view contain also the form for adding a task.

Which is the best practice for having a separate page that contain the form for add/edit tasks? I'm thinking about something like this:

Route::get('/edit/{task?}', function () { /**/ });

Using the optional {task?} parameter I can choose if it's an insert or an update, but I don't like so much specifying the action (edit) inside the URL.

Any suggestion?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire