There is something I would like to check with Laravel's route.
The error below has been resolved, but I don't know why it has been resolved.
Route [tasks.show] not defined.tasklist/resources/views/tasks/index.blade.php
If you change tasks.show to users.show, it will be resolved.
I thought tasks.show was show.blade.php in the tasks folder.
The users folder does not exist in my environment.
What is tasks in this task.show?
web.php
Route::get('/', 'TasksController@index');
// create —Form page for creating a new
Route::get('tasks/create','TasksController@create') ->name('tasks.create');
// User Registration
Route::get('signup', 'Auth\RegisterController@showRegistrationForm') ->name('signup.get');
Route::post('signup', 'Auth\RegisterController@register') ->name('signup.post');
// login authentication
Route::get('login','Auth\LoginController@showLoginForm') ->name('login');
Route::post('login','Auth\LoginController@login') ->name('login.post');
Route::get('logout', 'Auth\LoginController@logout') - > name('logout.get');
// User Features
Route::group(['middleware'=>['auth']], function(){
Route::resource('users','UsersController',['only'=>['index','show']]);
Route:: resource('tasks', 'TasksController', ['only'=>['store', 'destroy']]);
TasksController.php
public function show($id)
{
$task=Task::find($id);
return view('tasks.show',[
'task' = > $task,
]);
}
Name of the route configured on the router.
Check the route configuration file (e.g., routes/web.php). Do you have any routes defined like ->name('users.show')
?
I will add the answers to the router file.
In this case,
Route::resource('users', 'UsersController', ['only'=>['index', 'show']);
The routes cusers.index
" and odeusers.show
が are registered in .
If you change tasks.show to users.show, it will be resolved.
That's why(Probably, the behavior is not ideal just because the error disappears.)
Route::resource
autoregisters routes that provide CRUD, but often does not require everything, so you can whitelist them with only
.Here is index and show.
Be careful when using Route::resource in Ravel - Qiita
Controller 6.x Ravel
On the other hand, the routes for tasks are
Route::resource('tasks', 'TasksController', ['only'=>['store', 'destroy']]);
You are registered with the .(Only create is separated, but I will ignore it for now)
As with users, only tasks.store
and tasks.destroy
appear to be registered.Of course, show
is not included, so the route tasks.show
is not registered.
In other words, you can add show
here to solve the problem.
573 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
582 PHP ssh2_scp_send fails to send files as intended
578 Understanding How to Configure Google API Key
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
916 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.