Answer the question
In order to leave comments, you need to log in
Why can't it find the route in Laravel?
For some reason, the user.account route does not work, it gives an error:
Route [user.account] not defined. (View: /Users/vladimir/Desktop/lbog/resources/views/layouts/app.blade.php)
. After changing the routes, I wrote the php artisan route:clear command. The error is shown because of the sidebar in the template.<ul class="navbar-nav ml-auto">
@guest
<li class="nav-item">
<a class="nav-link" href="{{ route('auth.login') }}">Login</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('auth.register') }}">Sing up</a>
</li>
@else
<li class="nav-item">
<h4>{{ Auth::user()->name }}</h4>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('user.account') }}">My account</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{{ route('auth.logout') }}">Logout</a>
</li>
@endif
</ul>
Route::group([
'as' => 'user',
'prefix' => 'user',
'namespace' => 'User',
'middleware' => ['auth'],
], function(){
Route::post('account', [App\Http\Controllers\User\AccountController::class, 'account'])->name('account');
});
class AccountController extends Controller
{
public function account(Request $request){
return view('user.account');
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question