I have a button that href to a Route and the route go to function and the function returns a view file
but Laravel says that the view not found
the button href
href="{{ route('users.checks.edit', $check->id) }}"
the Route
Route::get('/users/editChecks/{user_id}', [UserController::class, 'editCheck'])->name('users.checks.edit');
the function
public function editCheck($id)
{
$check = Detail::findOrFail($id);
return view('users.checks.edit', compact('check'));
}
the views folder
the Error
CodePudding user response:
To refer page inside the sub directory, laravel uses the dot(.) notation. e.g to access the page users.checks.edit, laravel will look for the following directory structure inside views directory.
users/checks/edit.blade.php
As i can see there is no checks directory inside the views folder, that's why laravel is not getting the exact page you are looking for and in result giving the view not found error.
But you do have a page named users.checks.edit.blade.php in your views directory but laravel considers every dot before .blade.php as the directory. So in short, laravel is looking your page inside users/checks/edit.blade.php but there is no such directory.
rename you file to something like users_checks_edit.blade.php and then call from controller with same name or move it to the sub directory like users/checks/edit.blade.php
I hope this will answer the question.