Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

RouteName and ModelName is same in Controller resource problem

image_1

image_2

is there a way for the routeName (number 1) and modelName(number 2) to be different ??
(define both separately)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can tell Laravel to change the name wildcard by chaining on the the parameter() method:

Route::resource('article', ArticleController::class)->parameter('article', 'new_name');

The first argument is the current name (article) and the second parameter is the "new name".


In your case, since you want to change the route to "admin" but keep the name article for the wildcard, you should be able to do:

Route::resource('admin', ArticleController::class)->parameter('admin', 'article');

NB in the case of hyphenated routes, the 1st argument for parameter will actually be the snake-case version e.g.

Route::resource('foo-bar', FooBarController::class)->parameter('foo_bar', 'new_name');
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading