好的,我有一个资源,其中show($ id = create)正在接管create()
我正在访问的页面
http://localhost/admin/packages/create
我的错误是:错误
ModelNotFoundException {#306 ▼
#model: "Me\Subscriptions\Package"
#ids: []
#message: "No query results for model [Me\Subscriptions\Package]."
#code: 0
#file: "C:\Users\Me\Code\bb2\vendor\laravel\framework\src\Illuminate\Routing\ImplicitRouteBinding.php"
#line: 36
trace: {▶}
}
我的资源档案: routes / admin.php
// I commented out every other line...
Route::resource('/packages', 'PackagesController');
我的控制器已填充所有资源方法... PackagesController
...
public function show(Package $package) {
$meals = Meal::all();
return view('admin.packages.show')
->with(compact('package', 'meals'));
}
public function create() {
return view('admin.packages.create');
}
...
当我运行路线:列表
时| | GET|HEAD | admin/packages | packages.index | App\Http\Controllers\Admin\PackagesController@index | admin |
| | POST | admin/packages | packages.store | App\Http\Controllers\Admin\PackagesController@store | admin |
| | GET|HEAD | admin/packages/create | packages.create | App\Http\Controllers\Admin\PackagesController@create | admin |
| | DELETE | admin/packages/{package} | packages.destroy | App\Http\Controllers\Admin\PackagesController@destroy | admin |
| | PUT|PATCH | admin/packages/{package} | packages.update | App\Http\Controllers\Admin\PackagesController@update | admin |
| | GET|HEAD | admin/packages/{package} | packages.show | App\Http\Controllers\Admin\PackagesController@show | admin |
| | GET|HEAD | admin/packages/{package}/edit | packages.edit | App\Http\Controllers\Admin\PackagesController@edit | admin
我也检查了 RouteServiceProvider ......
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
parent::boot();
}
public function map()
{
$this->mapAdminRoutes();
}
protected function mapAdminRoutes()
{
Route::group([
'middleware' => 'admin',
'namespace' => $this->adminNamespace,
'prefix' => 'admin',
], function ($router) {
require base_path('routes/admin.php');
});
}
我错过了什么??????
答案 0 :(得分:2)
执行composer update
为我解决了这个问题。
显然,laravel / framework
版本5.5.7中存在问题更新到5.5.8 ^以修复此问题。+