I have the following Route:
Route::resource('projects.deliveries.tasks', 'TaskController');
And of course if I want to create a task, my URL looks like this:
http:://test.dev/projects/1/deliveries/3/tasks/create
For Project Number 1 and delivery number 3.
http://i.imgur.com/RlHHY31.jpg
But I don't want the number to show up in the URL, because tasks should be creatable, without authentication or login.
Is there a way to hide these numbers, so that I get a clean URL like this:
http:://test.dev/projects/delivereis/tasks/create
And Laravel understands from my logic, that it is Project 1 and devivery 3 for which a task is to be created?
If you want to do this, you should probably specify your routes manually. Using Route::resource()
is great if you're absolutely going to use the resource as intended (with verbose routes) but it doesn't provide you with much flexibility. In fact for most projects it's actually recommended that you do define all your routes manually to give you the most control (and it's also great self-documentation in your routes.php
file).
Route::get('projects/deliveries/tasks/create', ['as' => 'projects.deliveries.tasks.create', 'uses' => 'TasksController@create']);
Route::post('projects/deliveries/tasks', ['as' => 'projects.deliveries.tasks.store', 'uses' => 'TasksController@store']);