我正在将Laravel从5.2升级到5.3。在5.2中,我正在抛出Illuminate\Contracts\Validation\ValidationException
(使用我自己的验证逻辑),如下所示:
$this->errors = new MessageBag();
...
ValidationException($this->errors);
在5.3中,Illuminate\Contracts\Validation\ValidationException
被删除。如何保持相同的刀片输出行为?我只是重新创建ValidationException
?
// In blade, this should still print error. (JSON should keep same behaviour too)
@if (count($errors) > 0)
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif