Laravel Best Routing Practice

There are three routes to the laravel 5.2 baseline tutorial:

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

First, tasks are listed, the second is for adding a task, and the last for deleting a task. In the tutorial, the listing view also contains a form for adding a task.

What is the best practice for having a separate page containing a form for adding / editing tasks? I am thinking of something like this:

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

Using the optional {task?} Parameter, I can choose whether this is an insert or update, but I don’t like that much action (editing) indication inside the URL.

Any suggestion?

+4
source share
1 answer

CRUD Laravel :

php artisan make:controller TaskController --resource

Route::resource() . , 7 CRUD:

Route::resource('task', 'TaskController');
+3

Source: https://habr.com/ru/post/1661922/


All Articles