Kate Cebotari
Kate Cebotari

Reputation: 309

Laravel beginner. Html href redirect to a named route

I am relatively new to Laravel so I don't understand well all its features.

My routes:

Route::get('/', ['as' => 'index', 'uses' => 'PageController@index']);
Route::get('/contact', ['as' => 'contact', 'uses' => 'PageController@contact']);
Route::get('/cart', ['as' => 'cart', 'uses' => 'PageController@cart']);
Route::get('/checkout', ['as' => 'checkout', 'uses' => 'PageController@checkout']);

now the question is how to redirect from html using blade templates to the named route:

I tried:

<li><a href="{{ route('index') }}">HOME</a></li>

but it redirects to /index instead of /.

What would be the correct solution for redirect using {{ route('XXXX') }} ?

Upvotes: 0

Views: 245

Answers (1)

Prince Lionel N&#39;zi
Prince Lionel N&#39;zi

Reputation: 2588

You can do

<li><a href="{{ url('/') }}">HOME</a></li>

UPDATED

Run the following commands:

  1. php artisan route:clear
  2. php artisan cache:clear

Upvotes: 1

Related Questions