'How to set custom laravel resource controller request url

enter image description here

I want to change the default request url! ex.

GET /photos/{photo}/edit change to /photos/{photo}/update GET /photos/create change to /photos/createOnePhoto



Solution 1:[1]

You can't change default resource() routes. You can tell Laravel to not build some of them by using ->except(['update', 'create']).

Add all custom routes manually:

Route::get('photos/createOnePhoto', ['as' => 'photo.createOne', 'uses' => 'PhotoController@createOnePhoto'])

Solution 2:[2]

In Laravel 9 you can use Localizing Resource URIs on your App\Providers\RouteServiceProvider.

public function boot()
{
    Route::resourceVerbs([
        'create' => 'crear',
        'edit' => 'editar',
    ]);
 
    // ...
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alexey Mezenin
Solution 2 Matheus Dal'Pizzol