'Route not found even though It's defined

This is the error that I get rolled out (View: Route [user.profile] not defined. (View: D:\Programi\XAMPP\htdocs\crushapp\resources\views\layouts\base.blade.php)

But my route is clearly defined here:

use App\Http\Livewire\User\ProfileComponent;
Route::middleware(['auth:sanctum','verified'])->group(function()
{
    Route::get('/user/profile',ProfileComponent::class)->name('user.profile');
    
});

The error comes from the layout, namely:

<span><i class="fa fa-user-circle-o" aria-hidden="true"></i> <a href="{{ route('user.profile') }}">{{ Auth::user()->name }}  ‎‎‏‏‎ ‎‎‏‏</a></span>

Any ideas what could it be?

UPDATE: Any new route I try defining under user won't work...



Solution 1:[1]

first you are missing a function name in your route also run php artisan route:clear

Route::get('/user/profile',ProfileComponent::class, 'index')->name('user.profile')

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Praise Adeala