count()参数必须是在laravel中实现可计数的数组或对象 [英] count() parameter must be an array or an object that implements countable in laravel

查看:127
本文介绍了count()参数必须是在laravel中实现可计数的数组或对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是这里的代码:

protected function credentials(Request $request)
{
    $admin=admin::where('email',$request->email)->first();
    if(count($admin))
    {
       if($admin->status==0){
           return ['email'=>'inactive','password'=>'You are not an active person, Please contact to admin'];
           }
           else{
               return ['email'=>$request->email,'password'=>$request->password,'status'=>1];
           }
       }
       return $request->only($this->username(), 'password');
    }

当我运行代码时,此错误变为:

When i run the code this error become:

"count():参数必须是实现Countable的数组或对象"

"count(): Parameter must be an array or an object that implements Countable"

推荐答案

这是我的解决方案:

count(array($variable));

希望它能起作用!

这篇关于count()参数必须是在laravel中实现可计数的数组或对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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