0

I want to show a link if the route is not the current route, however I'm getting an error when I try to include the link.
In my header blade:

    <a class="{{ Route::is('start') ? 'active' : '' }}"
  href="{{ URL::route('start') }}">Start</a>

In my web.php:

Route::get('/start', 'Start');

I'm getting the error: Route [start] not defined. (View: /var/app/current/resources/views/include/header.blade.php)

My start route works if I go to myurl/start, but when I add it to my header it throws the error. I ultimately want to only display the link on non-start route pages.

3
  • What version of Laravel are you in? Commented Aug 24, 2018 at 0:52
  • Follow docs how to set route. Commented Aug 24, 2018 at 0:56
  • Laravel version is 5.6 Commented Aug 24, 2018 at 0:58

2 Answers 2

2

You probably have to apply a "named route" for your route. I'm leaving you a link here below:

Named Routes in Laravel 5.5

In your route above this would become Route::get('/start', 'Start')->name('start')'

Notice the ->name('start') at the end. Then you'll be able to reference the route just by its name.

Sign up to request clarification or add additional context in comments.

Comments

0

I think the error caused by the difference of the first character between "start" and "Start".

In web.php, you use 'Start' while in blade file is 'start'. Please correct it and check again.

Hope it works well

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.