首页 > 解决方案 > Laravel 中未定义的变量 $pending

问题描述

尝试使用 where 条件获取计数时出现未定义的变量错误。

事务控制器.php

public function index()
{
    $pending = transactions::where('trans_status','Pending')->showProduct('0');
    
    return view('layouts.content', 
            ['pending' => $pending]);
}

content.blade.php

<h2 class="text-right"><i class="ti-alert f-left"></i><span>{{count($pending)}}</span></h2>

在此处输入图像描述

标签: laravel

解决方案


推荐阅读