企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
编辑文章页面和新建文章页面很相似,显示错误提示的代码是相同的。下面使用局部视图去掉两个视图中的重复代码。 新建 app/views/notifications.blade.php 文件,写入以下代码: ~~~ @if ($errors->any()) <div id="error_explanation"> <h2>{{ count($errors->all()) }} prohibited this article from being saved:</h2> <ul> @foreach ($errors->all() as $message) <li>{{ $message }}</li> @endforeach </ul> </div> @endif ~~~ 下面来修改 app/views/articles/creat.blade.php 和 edit.blade.php 视图,使用新建的局部视图,把其中的上面代码全删掉,替换成: ~~~ @include('notifications') ~~~