运行测试时出现此错误:
ModelNotFoundException:没有针对模型[App \ Content]的查询结果
这是我的测试:
/** @test */
public function it_loads_homepage()
{
$this->withoutExceptionHandling();
$response = $this->get('/');
$response->assertStatus(200);
}
这是我的控制器:
public function home()
{
$topbar = Content::where('slug', 'topbar')->firstOrFail();
return view('welcome')->with([
'logo' => Arr::get($topbar->content, 'logo', asset('images/logo.png')),
'quote' => Arr::get($topbar->content, 'quote'),
'quote_author' => Arr::get($topbar->content, 'quote_author')
]);
}
这是我的路线文件:
Route::get('/', 'PageController@home');
Route::post('/admin/content', 'ContentsController@store');
Auth::routes();
Route::get('/home', 'HomeController@index')->name('home');
Route::middleware('auth')->prefix('admin')->group(function () {
Route::get('/dashboard', 'DashboardsController@index');
Route::patch('/contents/{content}', 'ContentsController@update');
});
如果有人对如何帮助有任何想法,将不胜感激,谢谢!
附注:如果需要添加其他任何内容,请告诉我,谢谢!
暮色呼如
汪汪一只猫