ux.engineer
ux.engineer

Reputation: 11338

Laravel 5.5 get route path for a named route?

How can I access route path for a named route in Laravel 5.5? As far as I've searched for this syntax, I haven't found such.

Upvotes: 1

Views: 1722

Answers (2)

redcenter
redcenter

Reputation: 836

To directly redirect to a named route, use:

return redirect()->route('NAME');

To see the path to a named route, use:

echo route('NAME');

Upvotes: 1

Rutvij Kothari
Rutvij Kothari

Reputation: 1285

Name Route Path in Web.php

Route::get('/', 'ModelController@index')->name('model.index');
Route::get('/create', 'ModelController@create')->name('model.create');
Route::get('/edit/{paramerter}', 'ModelController@edit')->name('model.edit');

Accessing Route Path: route('model.index')

Passing Parameter: route('model.edit', ['parameter'=> $value])

Upvotes: 1

Related Questions