【发布时间】:2018-01-21 17:07:24
【问题描述】:
我使用 laravel 5.5,我创建了一个视图,用于在 views/back/categories/edit 中编辑类别 这是我在 CategoriesController 中的编辑功能
public function edit($id)
{
$category = Categories::getall();
$categories = Categories::find($id);
return view('back.categories.edit', ['categories' => $categories, 'category' => $category]);
}
这是我的路线
Route::group(['middleware'=>'admin'],function(){
Route::get('/dashboard','BackendController@index')->name('backend');
Route::group(['prefix' => 'categories'], function () {
Route::any('/show/{id}', ['as' => 'backend.categories.show', 'uses' => 'backend\CategoriesController@show']);
Route::get('/index', ['as' => 'back.categories.index', 'uses' => 'backend\CategoriesController@index']);
Route::any('/store', ['as' => 'back.categories.store', 'uses' => 'backend\CategoriesController@store']);
Route::any('/create', ['as' => 'back.categories.create', 'uses' => 'backend\CategoriesController@create']);
Route::any('/edit/{id}', ['as' => 'back.categories.edit', 'uses' => 'backend\CategoriesController@edit']);
Route::any('/update', ['as' => 'back.categories.update', 'uses' => 'backend\CategoriesController@update']);
Route::any('/destroy/{id}', ['as' => 'back.categories.destroy', 'uses' => 'backend\CategoriesController@destroy']);
});
});
我的编辑按钮
<a href="{{ url('back/categories/edit/'.$category->cat_id) }}" class="btn btn-success btn-sm">
<span class="fa fa-edit"></span> edit</a>
当我单击编辑按钮时,它会返回“抱歉,找不到您要查找的页面”的页面。文本和 URL :"back/categories/edit/4"
【问题讨论】:
-
这些路由是否使用
back前缀? -
我不这么认为,我的索引和创建路由工作,但我不知道为什么我的编辑路由不能返回视图。我试图看到我的视图有问题,但它如果我将该视图放在其他要查看的路线中仍然有效,但不是编辑路线
-
请显示指向
index路由的链接示例。 -
url('/back/categories/edit/'.$category->cat_id) -
@Sohel0415 这将创建完全相同的完整 URL。