web.php
name("home");
Route::get('/posts/{post:slug}',[PostsController::class,'show'])->name("posts.show");
Route::post('/posts/{post:slug}',[PostsController::class,'addComment'])->name("posts.add_comment");
Route::get('/contact', [ContactController::class , 'create'])->name("contact.create");
Route::post('/contact', [ContactController::class , 'store'])->name("contact.store");
Route::get('/about', AboutController::class)->name("about");
Route::get('/categories/{category:slug}',[CategoryController::class,'show'])->name("categories.show");
Route::get('/categories',[CategoryController::class,'index'])->name("categories.index");
/// /tags/{tag:slug} === SHOULD BE /tags/{tag:name}
Route::get('/tags/{tag:name}',[TagController::class,'show'])->name("tags.show");
// Admin Dashboard
//Route::get('/admin',[DashboardController::class,'index'])->name("admin.index");
Route::prefix('admin')->name('admin.')->middleware(['auth','isadmin'])->group(function(){
Route::get('/',[DashboardController::class,'index'])->name("index");
Route::post('upload_tinymce_image',[TinyMCEController::class,'upload_tinymce_image'])->name('upload_tinymce_image');
Route::resource('posts',AdminPostsController::class);
Route::resource('categories',AdminCategoriesController::class);
});
require __DIR__.'/auth.php';
AdminCategoriesController.php
$category
]);
}
public function edit(Category $category)
{
return view('dashboard.categories.edit', [
'category' => $category
]);
}
public function update(Request $request, Category $category)
{
}
public function destroy(Category $category)
{
}
}
nav.blade.php
我开发了一个博客,并且有一个用于帖子的资源控制器,并且当我为类别创建另一个资源控制器时工作正常,给出了错误“路线 [admin.categories.index] 未定义”。 。 只是我将路线放在仪表板中,如果我在 nav.blade.php 文件中评论了类别的两条路线,错误就会引发并消失
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
根据 Laravel 9 文档
Route::resources([ 'posts' => AdminPostsController::class, 'categories'=> AdminCategoriesController::class ]);然后我运行了 php artisan route:clear。 终于出现了路线。