Illuminate \ Support \ MessageBag :: has()缺少参数1 [英] Missing argument 1 for Illuminate\Support\MessageBag::has()

查看:56
本文介绍了Illuminate \ Support \ MessageBag :: has()缺少参数1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我访问Laravel项目时.它返回以下错误.如何解决.

When i access my Laravel Project. It Returns Following Errors. How to Solve It.

Missing argument 1 for Illuminate\Support\MessageBag::has(), called in /var/www/laravel/vendor/laravel/framework/src/Illuminate/Support/ViewErrorBag.php on line 92 and defined (View: /var/www/laravel/resources/views/welcome.blade.php)

在我的刀片服务器代码中:

  @if ($errors->has())
  <div class="alert alert-danger">
  @foreach ($errors->all() as $error)
    {{ $error }}<br>
  @endforeach
  </div>
  @endif

推荐答案

选中此行:

@if ($errors->has())

has()用于基于关系过滤选择模型.因此,它的行为与正常WHERE条件非常相似.如果仅使用has('relation'),则意味着您只希望获得在该关系中至少具有一个相关模型的模型.

has() is used to filter the selecting model based on a relationship. So it acts very similarly to a normal WHERE condition. If you just use has('relation') that means you only want to get the models that have at least one related model in this relation.

has()必须具有字符串索引作为其参数,以检查其是否存在.但是在您的情况下,它是空白的.

has() must have a string index as its parameter to check whether it exist or not. But in your case it is blank.

替换以下行:

@if ($errors->has())

使用

@if ( count( $errors ) > 0 )

然后重试.

这篇关于Illuminate \ Support \ MessageBag :: has()缺少参数1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆