S
S
Sergey Burduzha2021-12-24 14:14:30
Laravel
Sergey Burduzha, 2021-12-24 14:14:30

Route [admin.users.index] not defined. (View: /var/www/resources/views/layouts/partials/tabs.blade.php)?

Created a UserController controller of type resource.

Route::group([
    'prefix' => 'admin',
    'as' => 'admin.',
    'middleware' => 'auth'
], function () {
    Route::get('/', [\App\Http\Controllers\Admin\HomeController::class, 'index'])->name('index');
    Route::resource('users', '\App\Http\Controllers\Admin\UserController');
});

For each user there is a link to edit.
<a href="{{ route('admin.users.edit', $user) }}" class="btn btn-success mr-3">Edit</a>


Only an error pops up

. I don’t understand where I messed up.

Thanks in advance for your help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Burduzha, 2021-12-24
@serii81

Understood, the problem was in breadcrumbs.
It was necessary to pass the $user parameter, hence the app.blade.php template in the header.

// Home
Breadcrumbs::for('home', function (BreadcrumbTrail $trail) {
    $trail->push('Home', route('home'));
});


Breadcrumbs::for('login', function (BreadcrumbTrail $trail) {
    $trail->parent('home');
    $trail->push('Login', route('login'));
});

Breadcrumbs::for('register', function (BreadcrumbTrail $trail) {
    $trail->parent('home');
    $trail->push('Register', route('register'));
});

// Home > Blog
Breadcrumbs::for('contact', function (BreadcrumbTrail $trail) {
    $trail->parent('home');
    $trail->push('Contacts', route('contact'));
});

Breadcrumbs::for('admin.index', function ($trail) {
    $trail->push('Admin', route('admin.index'));
});


Breadcrumbs::for('admin.users.index', function (BreadcrumbTrail $trail) {
    $trail->parent('admin.index');
    $trail->push('Users', route('admin.users.index'));
});

Breadcrumbs::for('admin.users.create', function (BreadcrumbTrail $trail) {
    $trail->parent('admin.users.index');
    $trail->push('Create', route('admin.users.create'));
});

Breadcrumbs::for('admin.users.show', function (BreadcrumbTrail $trail, User $user) {
    $trail->parent('admin.users.index');
    $trail->push($user->name, route('admin.users.show', $user));
});

Breadcrumbs::for('admin.users.edit', function ($trail, User $user) {
    $trail->push('Edit', route('admin.users.edit', $user));
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question