Raven Choi
Raven Choi

Reputation: 83

Route in Laravel Blade show double prefix

I'm new in Laravel and now I'm trying to make link in my blade files.
I read that in many tutorials, you can just use href="{{route('mm-admin/blog')}}" to make it works.
And by works I mean the list should be like this "mm-admin/blog".
But what i get using that code is "mm-admin/mm-admin/blog".

I tried to remove the mm-admin from this code "route('mm-admin/blog')" and it returns error saying

blog isn't defined.

what is wrong with my code??

this is my blade file

<li class="{{ request()->is('mm-admin/dashboard') ? 'active' : '' }}">
    <a href="{{route('dashboard')}}">
       <i class="fas fa-home"></i> <span>Dashboard</span>
    </a>
</li>

and this is my web route

Route::group(['prefix' => 'mm-admin', 'as' => 'mm-admin.'], function () {
    Route::get('/', 'Admin\LoginController@showLoginForm')->name('login');
    Route::get('/login', 'Admin\LoginController@showLoginForm')->name('login');
    Route::post('/proseslogin', 'Admin\LoginController@login');
    Route::get('/blog', [
        'as'   => 'blog',
        'uses' => 'Admin\BlogController@index', 'middleware' => 'admin',
    ]);
});

Upvotes: 0

Views: 357

Answers (1)

Rouhollah Mazarei
Rouhollah Mazarei

Reputation: 4153

This should work:

href="{{route('mm-admin.blog')}}" 

Upvotes: 1

Related Questions