我在安装了elqouent sluggable包后,在我的laravel项目中遇到了这个错误....
这是我的错误
抱歉,找不到您要查找的页面。 (2/2)NotFoundHttpException模型[App \ Tag]没有查询结果。 Handler.php中的Handler.php(第131行) - 在Handler.php中的Handler.php(第109行)中的prepareException(对象(ModelNotFoundException))在Handler.php中的Handler-> render(object(Request),object(ModelNotFoundException))第47行)在Handler->渲染(对象(Request),对象(ModelNotFoundException))在Pipeline.php(第82行)的Pipeline-> handleException(object(Request),object(ModelNotFoundException))中的Pipeline.php(第55行在Pipeline-> Illuminate \ Routing {closure}(对象(Request))在VerifyCsrfToken.php(第65行)的VerifyCsrfToken->句柄(对象(请求),对象(Closure))中的Pipeline.php(第14行)在Pipeline-> Illuminate \ Pipeline {closure}(object(Request))在Pipeline.php(第53行)的Pipeline-> Illuminate \ Routing {closure}(object(Request))中的ShareErrorsFromSession.php(第49行)在Pipeline中的Pipeline.php(第148行)中的ShareErrorsFromSession->句柄(对象(Request),对象(Closure)) - > Pipeline.php中的Illuminate \ Pipeline {closure}(object(Request))(线路53)在Pipeline-> Illumina在Pipeline->中的Pipeline.php(第148行)的StartSession->句柄(对象(请求),对象(Closure))中的StartSession.php(第64行)中的路由{closure}(对象(Request))。 Pipeline中的Pipeline.php(第53行)中的Illuminate \ Pipeline {closure}(对象(请求)) - > AddQueuedCookiesToResponse->中的AddQueuedCookiesToResponse.php(第37行)中的Illuminate \ Routing {closure}(object(Request)) Pipeline中的Pipeline.php(第148行)中的handle(对象(Request),对象(Closure)) - > Illuminate \ Pipeline {closure}(对象(Request))Pipeline.php(第53行)在Pipeline->在Pipeline->中的Pipeline.php(第148行)中的EncryptCookies->处理(对象(请求),对象(Closure))的EncryptCookies.php(第59行)中的Illuminate \ Routing {closure}(object(Request))。 Pipeline中的Pipeline.php(第53行)中的Illuminate \ Pipeline {closure}(对象(请求)) - >管道中的Illuminate \ Routing {closure}(object(Request))(第102行) - >在Router.> runRouteWithinStack(对象)中的Router.php(第576行)中的(object(Closure)) (路由),对象(请求))在Router.xp(第535行)的Router-> dispatchToRoute(对象(请求))在Router.php(第513行)的Router-> dispatch(对象(请求))中管道中的Kernel-php(第174行) - > Illuminate \ Foundation \ Http {closure}(对象(请求))在Pipeline.php(第30行)中的管道 - > Illuminate \ Routing {closure}(对象(请求)) )在TransformsRequest.php(第30行)的TransformsRequest->句柄(对象(请求),对象(Closure))在Pipeline.php(第148行)的Pipeline-> Illuminate \ Pipeline {closure}(对象(请求)) )在Pipeline中的Pipeline.php(第53行) - > Illuminate \ Routing {closure}(对象(Request))在TransformsRequest.php(第30行)的TransformsRequest->句柄(对象(请求),对象(Closure)) )在Pipeline中的Pipeline.php(第148行) - > Illuminate \ Pipeline {closure}(对象(Request))在Pipeline.php(第53行)的Pipeline-> Illuminate \ Routing {closure}(对象(请求)) )在Valid中的ValidatePostSize.php(第27行)的ValidatePostSize->句柄(对象(Request),对象(Closure))管道上的peline.php(148行) - > Illuminate \ Pipeline {closure}(对象(Request))在Pipeline.php(第53行)的Pipeline-> Illuminate \ Routing {closure}(object(Request))in CheckForMaintenanceMode.php(第46行)位于Pipeline的Pipeline.php(第148行)中的CheckForMaintenanceMode-> handle(object(Request),object(Closure)) - > Illuminate \ Pipeline {closure}(object(Request))in管道中的Pipeline.php(第53行) - > Illuminate \ Routing {closure}(对象(请求))在Pipeline中的Pipeline.php(第102行) - >然后(对象(Closure))在Kernel.php中(行149)在Kernel-> sendRequestThroughRouter(对象(Request))在Kernel.php(第116行)的Kernel->句柄(对象(请求))在index.php(第53行)的require_once(' / server.php中的opt / lampp / htdocs / ECD-Website / public / index.php')(第21行)(1/2)ModelNotFoundException模型[App \ Tag]没有查询结果。在Builder.php(第395行)的Builder-> firstOrFail()位于ImplicitRouteBinding.php(第35行)的ImplicitRouteBinding :: resolveForRoute(object(Application),object(Route))中的Router.php(第648行)中的路由器 - > SubstituteBindings.php(第39行)中的SubstituteBindings.php(第39行),在Pipeline的Pipeline.php(第148行)中的handle(object(Request),object(Closure)) - > Illuminate \在Pipeline中的Pipeline.php(第53行)中的管道{closure}(对象(请求)) - > Illuminate \ Routing {closure}(对象(请求))在VerifyCsrfToken.php(第65行)的VerifyCsrfToken->句柄( Pipeline中的Pipeline.php(第148行)中的对象(Request),对象(Closure) - >管道中的Pipeline.php(第53行)中的Illuminate \ Pipeline {closure}(object(Request)) - > Illuminate \在Pipeline中的Pipeline.php(第148行)的ShareErrorsFromSession->处理(对象(请求),对象(Closure))中的ShareErrorsFromSession.php(第49行)中路由{closure}(对象(Request)) - > Illuminate \管道{闭合}(对象(请求))在Pipeline中的Pipeline.php(第53行) - > Illuminate \ Routing {closure}(对象(Request))在StartSession.php(第64行)的StartSession->句柄(对象(Request),对象(Closure) ))在Pipeline中的Pipeline.php(第148行) - > Illuminate \ Pipeline {closure}(对象(Request))在Pipeline.php(第53行)的Pipeline-> Illuminate \ Routing {closure}(对象(请求) ))在Pipeline中的Pipeline.php(第148行)的AddQueuedCookiesToResponse->句柄(对象(请求),对象(Closure))中的AddQueuedCookiesToResponse.php(第37行) - > Illuminate \ Pipeline {closure}(对象(请求) ))在Pipeline中的Pipeline.php(第53行) - > Illuminate \ Routing {closure}(object(Request))在EncryptCookies.php(第59行)的EncryptCookies->句柄(对象(Request),对象(Closure) ))在Pipeline中的Pipeline.php(第148行) - > Illuminate \ Pipeline {closure}(对象(Request))在Pipeline.php(第53行)的Pipeline-> Illuminate \ Routing {closure}(对象(请求) ))在Pipeline中的Pipeline.php(第102行) - >然后(对象(Closure))在Router.ph中在Router.php(第513行)中的Router-> dispatchToRoute(对象(请求))的Router.php(第535行)中的Router-> runRouteWithinStack(对象(路由),对象(请求))的p(第576行)位于Pipeline的Pipeline.php(第30行)中Kernel-> Illuminate \ Foundation \ Http {closure}(对象(请求))的Kernel.php(第174行)中的Router-> dispatch(object(Request)) - >在Pipelines-中Pipeline.php(第148行)的TransformsRequest->句柄(对象(请求),对象(Closure))中的TransformsRequest.php(第30行)中的Illuminate \ Routing {closure}(object(Request)) - > Illuminate \ Pipeline {closure}(object(Request))在Pipeline中的Pipeline.php(第53行) - > Illuminate \ Routing {closure}(object(Request))在TransformsRequest.php(第30行)中的TransformsRequest-管道中的Pipeline.php(第148行)中的>句柄(对象(请求),对象(闭包)) - 管道中的Pipeline.php(第53行)中的Illuminate \ Pipeline {closure}(对象(请求)) - >在ValidatePostSi的ValidatePostSize.php(第27行)中照亮\ routing {closure}(object(Request)) Pipeline中的Pipeline.php(第148行)中的ze->句柄(对象(Request),对象(Closure))> Pipeline.php(第53行)中的Illuminate \ Pipeline {closure}(object(Request))在Pipeline.php(第148行)的CheckForMaintenanceMode->句柄(对象(请求),对象(Closure))的CheckForMaintenanceMode.php(第46行)中的Pipeline-> Illuminate \ Routing {closure}(object(Request))at Pipeline-> Illuminate \ Pipeline {closure}(对象(Request))在Pipeline.php(第53行)的Pipeline-> Illuminate \ Routing {closure}(对象(Request))在Pipeline.php(第102行)at at管道 - >然后(对象(Closure))在内核中的Kernel.php(第149行) - >在内核中的Kernel.php(第116行)中的sendRequestThroughRouter(对象(请求))处理(对象(请求)) )在server.php(第21行)的require_once(' /opt/lampp/htdocs/ECD-Website/public/index.php')的index.php(第53行)中
这是我的 routes.php
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
/*
Backend Routes
*/
/**************Dashboard********************/
Route::get('/dash','Backend\DashboardController@index');
/***********Home Page **********************/
Route::get('/dashboard', 'Backend\HomeController@index');
Route::get('/home/edit/{id}', 'Backend\HomeController@edit');
Route::get('/home/create', 'Backend\HomeController@create');
Route::post('home/create','Backend\HomeController@store');
Route::delete('/homedelete/{id}', 'Backend\HomeController@destroy');
//Route::PATCH('home/edit/{id}','Backend\HomeController@update');
//Route::delete('home/{id}',['as'=>'home.destroy','uses'=>'Backend\HomeController@destroy']);
Route::patch('home/{id}',['as'=>'home.update','uses'=>'Backend\HomeController@update']);
/*****************************Causes********************************************/
Route::get('admin/causes', 'Backend\CausesController@index');
Route::get('/admin/causes/edit/{id}', 'Backend\CausesController@edit');
Route::get('admin/causes/create', 'Backend\CausesController@create');
Route::post('admin/causes/create','Backend\CausesController@store');
Route::PATCH('admin/causes/edit/{id}','Backend\CausesController@update');
Route::patch('admin/causes/{id}',['as'=>'causes.update','uses'=>'Backend\CausesController@update']);
Route::delete('admin/causes/{id}',['as'=>'causes.destroy','uses'=>'Backend\CausesController@destroy']);
/**********************project****************************************************/
Route::get('/admin/project', 'Backend\ProjectController@index');
Route::get('/admin/project/edit/{id}', 'Backend\ProjectController@edit');
Route::get('/admin/project/create', 'Backend\ProjectController@create');
Route::post('admin/project/create',['as'=>'project.create','uses'=>'Backend\ProjectController@store']);
Route::PATCH('admin/project/edit/{id}','Backend\ProjectController@update');
Route::patch('admin/project/{id}',['as'=>'project.update','uses'=>'Backend\ProjectController@update']);
Route::delete('admin/project/{id}',['as'=>'project.destroy','uses'=>'Backend\ProjectController@destroy']);
/**********************Event*******************************************************/
Route::get('/admin/events', 'Backend\EventController@index');
Route::get('/admin/events/create', 'Backend\EventController@create');
Route::post('/admin/events/create','Backend\EventController@store');
Route::delete('admin/events/{id}',['as'=>'events.destroy','uses'=>'Backend\EventController@destroy']);
Route::get('/admin/events/edit/{id}', 'Backend\EventController@edit');
Route::PATCH('admin/events/edit/{id}','Backend\EventController@update');
Route::patch('admin/events/{id}',['as'=>'events.update','uses'=>'Backend\EventController@update']);
/**********************history*******************************************/
Route::get('/admin/about/history', 'Backend\HistoryController@index');
Route::get('/admin/about/history/create', 'Backend\HistoryController@create');
Route::post('/admin/about/history/create','Backend\HistoryController@store');
Route::delete('admin/about/history/{id}',['as'=>'history.destroy','uses'=>'Backend\HistoryController@destroy']);
Route::get('/admin/about/history/edit/{id}', 'Backend\HistoryController@edit');
Route::PATCH('admin/about/history/edit/{id}','Backend\HistoryController@update');
Route::patch('admin/about/history/{id}',['as'=>'history.update','uses'=>'Backend\HistoryController@update']);
/**********************Address******************************************/
Route::get('/admin/about/address', 'Backend\ContactController@index');
Route::get('/admin/about/address/create', 'Backend\ContactController@create');
Route::post('/admin/about/address/create','Backend\ContactController@store');
Route::delete('admin/about/address/{id}',['as'=>'contact.destroy','uses'=>'Backend\ContactController@destroy']);
Route::get('/admin/about/address/edit/{id}', 'Backend\ContactController@edit');
Route::PATCH('admin/about/address/edit/{id}','Backend\ContactController@update');
Route::patch('admin/about/address/{id}',['as'=>'contact.update','uses'=>'Backend\ContactController@update']);
Route::get('/admin/message', 'Backend\MessageController@index');
Route::delete('admin/message/{id}',['as'=>'message.destroy','uses'=>'Backend\MessageController@destroy']);
/**********************Category****************************************************/
Route::get('/admin/category', 'Backend\CategoryController@index');
Route::get('/admin/category/edit/{id}', 'Backend\CategoryController@edit');
Route::get('/admin/category/create', 'Backend\CategoryController@create');
Route::post('admin/category/create',['as'=>'category.create','uses'=>'Backend\CategoryController@store']);
Route::PATCH('admin/category/edit/{id}','Backend\CategoryController@update');
Route::patch('admin/category/{id}',['as'=>'category.update','uses'=>'Backend\CategoryController@update']);
Route::delete('admin/category/{id}',['as'=>'category.destroy','uses'=>'Backend\CategoryController@destroy']);
/**********************Tag****************************************************/
Route::get('/admin/tag', 'Backend\TagController@index');
Route::get('/admin/tag/edit/{id}', 'Backend\TagController@edit');
Route::get('/admin/tag/create', 'Backend\TagController@create');
Route::post('admin/tag/create',['as'=>'tag.create','uses'=>'Backend\TagController@store']);
Route::PATCH('admin/tag/edit/{id}','Backend\TagController@update');
Route::patch('admin/tag/{id}',['as'=>'tag.update','uses'=>'Backend\TagController@update']);
Route::delete('admin/tag/{id}',['as'=>'tag.destroy','uses'=>'Backend\TagController@destroy']);
/*********************************blog*************************************************/
Route::get('/blogs', 'Backend\BlogController@index');
Route::get('/posts/create', 'Backend\BlogController@create');
Route::get('/posts/edit/{id}', 'Backend\BlogController@edit');
Route::post('/posts/', 'Backend\BlogController@store');
Route::patch('/posts/{id}', ['as'=>'blog.update','uses'=>'Backend\BlogController@update']);
/****************************Gallery************************************************/
Route::get('gallery/list', 'Backend\GalleryController@viewGalleryList');
Route::post('gallery/save', 'Backend\GalleryController@saveGallery');
Route::get('gallery/view/{id}', 'Backend\GalleryController@viewGalleryPics');
Route::post('image/do-upload', 'Backend\GalleryController@doImageUpload');
Route::get('gallery/delete/{id}','Backend\GalleryController@deleteGallery');
/*
Frontend Routes
*/
Route::get('/', 'Frontend\HomeController@index');
Route::get('project', 'Frontend\ProjectController@index');
Route::get('/aboutus', 'Frontend\AboutUsController@index');
Route::post('/message/create','Frontend\MessageController@store');
Route::get('causes', 'Frontend\CausesController@index');
Route::get('/cause-single/{slug}', 'Frontend\CausesController@index_detail');
Route::get('blog','Frontend\BlogController@index');
Route::get('project-detail/{slug}', 'Frontend\ProjectController@index_detail');
Route::get('gallery', 'Frontend\GalleryController@index');
Route::get('event', 'Frontend\EventController@index');
Route::get('event-detail/{slug}', 'Frontend\EventController@index_detail');
Route::get('volunteer', function () {
return view('frontend/volunteer');
});
Route::post('/volunteer/create','Frontend\VolunteerController@store');
Route::get('Mission_&_Vision', function () {
return view('frontend/our mission');
});
Route::get('project_sustainability', function () {
return view('frontend/Project-Sustainablity');
});
Route::get('contactus', function () {
return view('frontend/contactus');
});
Route::get('team', function () {
return view('frontend/team');
});
Route::get('testimonials', function () {
return view('frontend/testimonials');
});
Route::post('/posts/{post}/comments', 'Frontend\CommentController@store');
Route::get('/posts/{post}', 'Frontend\BlogController@show');
Route::get('/posts/tags/{tag}', 'Frontend\TagController@index');
Route::get('user/index', 'Backend\UserController@index');
Route::delete('user/index/{id}',['as'=>'user.destroy','uses'=>'Backend\UserController@destroy']);
Auth::routes();
Route::get('logout', '\App\Http\Controllers\Auth\LoginController@logout');
这是我的 TagController.php
<?php
namespace App\Http\Controllers\Frontend;
use App\Tag;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class TagController extends Controller
{
public function index(Tag $tag){
// return $tag;
$posts=$tag->posts;
return view('frontend.blog',compact('posts'));
}
}
我不知道造成这个错误的原因......它工作得很好!有什么帮助吗?我尝试更改标签的路线名称,并在顶部调整路线,但仍然面临这个错误......我是laravel的初学者,我无法解决这个问题..