php - 在 laravel 中找不到资源的奇怪问题
问题描述
我在一个博客网站工作。我有以下路线
/categories App\Http\Controllers\Frontend\Blog\CategoryController@index
/category/{slug} App\Http\Controllers\Frontend\Blog\CategoryController@show
/tags App\Http\Controllers\Frontend\Blog\TagController@index
/tag/{slug} App\Http\Controllers\Frontend\Blog\TagController@show
除 /tags 外,所有路线都运行良好
它显示以下屏幕。
当我将此路线更改为其他路线时,它可以完美运行,\tags
我\tag-listing
可能会错过什么问题?如果需要,我可以添加更多详细信息。
更新
RouteServiceProvider
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
//
parent::boot();
}
/**
* Define the routes for the application.
*
* @return void
*/
public function map()
{
$this->mapApiRoutes();
$this->mapWebRoutes();
$this->mapBackendRoutes();
$this->mapFrontendRoutes();
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiRoutes()
{
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
}
/**
* Define the "backend" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapBackendRoutes()
{
Route::prefix('backend')
->middleware('web','auth')
->namespace($this->namespace)
->group(base_path('routes/backend.php'));
}
/**
* Define the "backend" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapFrontendRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/frontend.php'));
}
}
路线/前端.php
<?php
$router->group(['namespace' => 'Frontend'], function ($router){
require app_path('Http/Routes/Frontend/home.php');
});
$router->group(['namespace' => 'Frontend\Blog'], function ($router){
require app_path('Http/Routes/Frontend/category.php');
require app_path('Http/Routes/Frontend/tag.php');
require app_path('Http/Routes/Frontend/post.php');
require app_path('Http/Routes/Frontend/page.php');
});
应用程序/Http/Routes/tag.php
<?php
$router->get('/tags', 'TagController@index')->name('frontend.tags');
$router->get('/tag/{slug}', 'TagController@show')->name('frontend.tags.show');
$router->get('/tag/{slug}/load-more-posts', 'TagController@loadMorePosts')->name('frontend.tags.load-more-posts');
$router->get('/load-more-tags', 'TagController@loadMoreTags')->name('frontend.tags.load-more');
应用程序/Http/Routes/category.php
<?php
$router->get('/categories', 'CategoryController@index')->name('frontend.categories');
$router->get('/category/{slug}', 'CategoryController@show')->name('frontend.categories.show');
$router->get('/category/{slug}/load-more-posts', 'CategoryController@loadMorePosts')->name('frontend.categories.load-more-posts');
$router->get('/load-more-categories', 'CategoryController@loadMoreCategories')->name('frontend.categories.load-more');
我不知道这里有什么问题。
解决方案
推荐阅读
- java - 将按钮添加到listview firebase arraylist strings android
- c - 如何在编译时定义由来自不同模块的静态(私有)结构组成的结构数组?
- c# - 如何在水晶报表中隐藏一个部分
- html - Gitignore 生成的 pdf 但不是所有的 pdf
- clojure - Clojure 和 Leiningen:为什么在这个例子中需要 `doall`?
- c# - 如何使用 openfiledialog 在 C# 中以文本形式打开任何文件?
- python - 为什么这个 python 代码会使我的网站崩溃?而这个其他python代码没有?
- c++ - C++,处理多个构造函数重载和冗余代码
- python - 使用 bool(TheClassItself) 返回 False 的类
- excel - 对字符串的出现求和