Laravel 8 共享错误
一些视图可能依赖于 Laravel 提供的全局错误包中共享的错误。要在错误包中生成错误消息,可以使用 withViewErrors
方法:
$view = $this->withViewErrors([
'name' => ['Please provide a valid name.']
])->view('form');
$view->assertSee('Please provide a valid name.');
一些视图可能依赖于 Laravel 提供的全局错误包中共享的错误。要在错误包中生成错误消息,可以使用 withViewErrors
方法:
$view = $this->withViewErrors([
'name' => ['Please provide a valid name.']
])->view('form');
$view->assertSee('Please provide a valid name.');